-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-41491: plistlib: accept hexadecimal integer values in xml plist f… #22764
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I wonder if it would be worth opening a new issue to enhance test_plistlib to do some comparisons with the output from plutil when the test is running on macOS.
I filed bpo-42095 for the additional tests. Having those would be useful to check interop, but wouldn't have found this particular issue. |
Thanks @ronaldoussoren for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
GH-22806 is a backport of this pull request to the 3.9 branch. |
…iles (pythonGH-22764) (cherry picked from commit 3185267) Co-authored-by: Ronald Oussoren <[email protected]>
…iles (pythonGH-22764) (cherry picked from commit 3185267) Co-authored-by: Ronald Oussoren <[email protected]>
GH-22807 is a backport of this pull request to the 3.8 branch. |
…iles (GH-22764) (GH-22806) (cherry picked from commit 3185267) Co-authored-by: Ronald Oussoren <[email protected]>
…iles (GH-22764) (GH-22807) (cherry picked from commit 3185267) Co-authored-by: Ronald Oussoren <[email protected]> Co-authored-by: Ronald Oussoren <[email protected]>
|
|
|
@@ -245,7 +245,11 @@ def end_false(self): | |||
self.add_object(False) | |||
|
|||
def end_integer(self): | |||
self.add_object(int(self.get_data())) | |||
raw = self.get_data() | |||
if raw.startswith('0x') or raw.startswith('0X'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raw.startswith(('0x', '0X'))
or
raw[:2] in ('0x', '0X')
You can also use int(raw, 0)
to parse decimal and hexadecimal literals (also octal and binary).
Turns out that Apple's plist parsing code accepts hexadecimal notation in tags.
https://bugs.python.org/issue41491