mirror of
https://github.com/corpnewt/gibMacOS.git
synced 2025-03-21 14:49:52 +01: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
@ -61,12 +61,9 @@ def load(fp, fmt=None, use_builtin_types=True, dict_type=dict):
|
||||
return readBinaryPlistFile(fp)
|
||||
|
||||
def loads(value, fmt=None, use_builtin_types=True, dict_type=dict):
|
||||
if isinstance(value, _get_inst()):
|
||||
# We were sent a string - let's encode it to some utf-8 bytes for fun!
|
||||
try:
|
||||
value = value.encode("utf-8")
|
||||
except:
|
||||
pass
|
||||
if _check_py3() and isinstance(value, _get_inst()):
|
||||
# We were sent a string in py3 - let's encode it to some utf-8 bytes for fun!
|
||||
value = value.encode()
|
||||
fp = BytesIO(value)
|
||||
if _check_py3():
|
||||
return plistlib.load(fp, fmt=fmt, use_builtin_types=use_builtin_types, dict_type=dict_type)
|
||||
|
Loading…
Reference in New Issue
Block a user