Force StringIO in lieu of cStringIO

This commit is contained in:
CorpNewt 2018-11-13 09:42:16 -06:00 committed by GitHub
parent 7333fdb330
commit 7072baa61e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,9 @@
import datetime
from io import BytesIO
# Force use of StringIO instead of cStringIO as the latter
# has issues with Unicode strings
from StringIO import StringIO
import os
import plistlib
import struct
@ -76,8 +79,9 @@ def loads(value, fmt=None, use_builtin_types=True, dict_type=dict):
return readBinaryPlistFile(BytesIO(value))
else:
# Is not binary - assume a string - and try to load
return plistlib.readPlistFromString(value)
# We avoid using readPlistFromString() as that uses
# cStringIO and fails when Unicode strings are detected
return plistlib.readPlist(StringIO(value))
def dump(value, fp, fmt=FMT_XML, sort_keys=True, skipkeys=False):
if _check_py3():