mirror of
https://github.com/corpnewt/gibMacOS.git
synced 2024-09-20 01:30:33 +00:00
String conversion for BytesIO fix
Only convert str vars to data when py3 in loads() as py2 plistlib can handle str and unicode without encoding
This commit is contained in:
parent
5484f9920c
commit
092ace29ec
1 changed files with 3 additions and 6 deletions
|
@ -61,12 +61,9 @@ def load(fp, fmt=None, use_builtin_types=True, dict_type=dict):
|
||||||
return readBinaryPlistFile(fp)
|
return readBinaryPlistFile(fp)
|
||||||
|
|
||||||
def loads(value, fmt=None, use_builtin_types=True, dict_type=dict):
|
def loads(value, fmt=None, use_builtin_types=True, dict_type=dict):
|
||||||
if isinstance(value, _get_inst()):
|
if _check_py3() and isinstance(value, _get_inst()):
|
||||||
# We were sent a string - let's encode it to some utf-8 bytes for fun!
|
# We were sent a string in py3 - let's encode it to some utf-8 bytes for fun!
|
||||||
try:
|
value = value.encode()
|
||||||
value = value.encode("utf-8")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
fp = BytesIO(value)
|
fp = BytesIO(value)
|
||||||
if _check_py3():
|
if _check_py3():
|
||||||
return plistlib.load(fp, fmt=fmt, use_builtin_types=use_builtin_types, dict_type=dict_type)
|
return plistlib.load(fp, fmt=fmt, use_builtin_types=use_builtin_types, dict_type=dict_type)
|
||||||
|
|
Loading…
Reference in a new issue