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:
CorpNewt 2018-09-26 19:31:03 -05:00 committed by GitHub
parent 5484f9920c
commit 092ace29ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 6 deletions

View File

@ -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)