fix: decode bytes not str (easy_xml.py)#160
Open
owl-from-hogvarts wants to merge 1 commit intonodejs:mainfrom
Open
fix: decode bytes not str (easy_xml.py)#160owl-from-hogvarts wants to merge 1 commit intonodejs:mainfrom
owl-from-hogvarts wants to merge 1 commit intonodejs:mainfrom
Conversation
Contributor
|
Please rebase so we can ensure that the tests pass. |
proper fix for nodejs#118 Special thanks to @cclauss
e0c0ad4 to
67393c1
Compare
Contributor
Author
Done |
legendecas
reviewed
Jun 18, 2024
| xml_string = xml_string.encode(encoding) | ||
| if sys.platform == "win32": | ||
| if isinstance(xml_string, str): | ||
| xml_string = xml_string.decode("cp1251") # str --> bytes |
Member
There was a problem hiding this comment.
This seems incorrect to me. XmlToString always returns a str and a str object has no attribute decode.
Contributor
There was a problem hiding this comment.
Correct: str.encode() and bytes.decode() exist but the opposites are undefined.
>>> for s_or_b in ("s", b"b"):
... for method_name in ("encode", "decode"):
... print(f"{s_or_b}: {method_name} is {getattr(s_or_b, method_name, None)}")
...
s: encode is <built-in method encode of str object at 0x103cbe928>
s: decode is None
b'b': encode is None
b'b': decode is <built-in method decode of bytes object at 0x103cb4bf0>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See nodejs/node-gyp/issues/2505
proper fix for #118
Special thanks to @cclauss