bpo-41491: plistlib: accept hexadecimal integer values in xml plist files (GH-22764) (GH-22806)
(cherry picked from commit 3185267400be853404f22a1e06bb9fe1210735c7)
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
diff --git a/Lib/plistlib.py b/Lib/plistlib.py
index ba7ac19..a740351 100644
--- a/Lib/plistlib.py
+++ b/Lib/plistlib.py
@@ -252,7 +252,11 @@
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'):
+ self.add_object(int(raw, 16))
+ else:
+ self.add_object(int(raw))
def end_real(self):
self.add_object(float(self.get_data()))