mirror of
https://github.com/corpnewt/gibMacOS.git
synced 2024-11-13 10:14:03 +01:00
Merge pull request #147 from cheesycod/master
Python 3.9 compat: Python 3.9 removed the use_builtin_types parameter used in Scripts/plist.py
This commit is contained in:
commit
64f98e0c63
@ -74,7 +74,11 @@ def load(fp, fmt=None, use_builtin_types=None, dict_type=dict):
|
||||
raise plistlib.InvalidFileException()
|
||||
else:
|
||||
P = plistlib._FORMATS[fmt]['parser']
|
||||
p = P(use_builtin_types=use_builtin_types, dict_type=dict_type)
|
||||
try:
|
||||
p = P(use_builtin_types=use_builtin_types, dict_type=dict_type)
|
||||
except:
|
||||
# Python 3.9 removed use_builtin_types
|
||||
p = P(dict_type=dict_type)
|
||||
if isinstance(p,plistlib._PlistParser):
|
||||
# Monkey patch!
|
||||
def end_integer():
|
||||
@ -116,15 +120,22 @@ def load(fp, fmt=None, use_builtin_types=None, dict_type=dict):
|
||||
return p.root
|
||||
else:
|
||||
use_builtin_types = False if use_builtin_types == None else use_builtin_types
|
||||
p = _BinaryPlistParser(use_builtin_types=use_builtin_types, dict_type=dict_type)
|
||||
try:
|
||||
p = _BinaryPlistParser(use_builtin_types=use_builtin_types, dict_type=dict_type)
|
||||
except:
|
||||
# Python 3.9 removed use_builtin_types
|
||||
p = _BinaryPlistParser(dict_type=dict_type)
|
||||
return p.parse(fp)
|
||||
|
||||
def loads(value, fmt=None, use_builtin_types=None, dict_type=dict):
|
||||
if _check_py3() and isinstance(value, basestring):
|
||||
# If it's a string - encode it
|
||||
value = value.encode()
|
||||
return load(BytesIO(value),fmt=fmt,use_builtin_types=use_builtin_types,dict_type=dict_type)
|
||||
|
||||
try:
|
||||
return load(BytesIO(value),fmt=fmt,use_builtin_types=use_builtin_types,dict_type=dict_type)
|
||||
except:
|
||||
# Python 3.9 removed use_builtin_types
|
||||
return load(BytesIO(value),fmt=fmt,dict_type=dict_type)
|
||||
def dump(value, fp, fmt=FMT_XML, sort_keys=True, skipkeys=False):
|
||||
if _check_py3():
|
||||
plistlib.dump(value, fp, fmt=fmt, sort_keys=sort_keys, skipkeys=skipkeys)
|
||||
|
Loading…
Reference in New Issue
Block a user