Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for calling .decode(...) on str objects #1758

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

patrick-nicholson
Copy link

Fixing a string behavior error (py2->py3 change) that prevented me from upgrading a very old database file

@Nick-Hall Nick-Hall added the bug label Aug 25, 2024
Comment on lines 320 to 322
if isinstance(parent_handle, str):
parent_handle = parent_handle.encode()
placeref_list = [(parent_handle.decode("utf-8"), None)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems only used here; it would be simpler to set placeref_list directly instead of encoding and decoding again.

Suggested change
if isinstance(parent_handle, str):
parent_handle = parent_handle.encode()
placeref_list = [(parent_handle.decode("utf-8"), None)]
if isinstance(parent_handle, str):
placeref_list = [(parent_handle, None)]
else:
placeref_list = [(parent_handle.decode("utf-8"), None)]

Comment on lines 492 to 494
if isinstance(parent, str):
parent = parent.encode()
placeref_list = [(parent.decode("utf-8"), None)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Suggested change
if isinstance(parent, str):
parent = parent.encode()
placeref_list = [(parent.decode("utf-8"), None)]
if isinstance(parent, str):
placeref_list = [(parent, None)]
else:
placeref_list = [(parent.decode("utf-8"), None)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants