Bypass cStringIO for writes too

This commit is contained in:
CorpNewt 2018-11-13 09:58:23 -06:00 committed by GitHub
parent 7072baa61e
commit 2e12e6f530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,7 +93,12 @@ def dumps(value, fmt=FMT_XML, skipkeys=False):
if _check_py3():
return plistlib.dumps(value, fmt=fmt, skipkeys=skipkeys).decode("utf-8")
else:
return plistlib.writePlistToString(value)
# We avoid using writePlistToString() as that uses
# cStringIO and fails when Unicode strings are detected
# return plistlib.writePlistToString(value)
f = StringIO()
plistlib.writePlist(value, f)
return f.getvalue()
### ###
# Binary Plist Stuff For Py2 #