Author: Alex Gaynor <[email protected]>
Branch: stdlib-2.7.8
Changeset: r73096:e76da23f2351
Date: 2014-08-27 10:26 -0700
http://bitbucket.org/pypy/pypy/changeset/e76da23f2351/
Log: Fix decoding of some values in tkapp, obscure rules
diff --git a/lib_pypy/_tkinter/tclobj.py b/lib_pypy/_tkinter/tclobj.py
--- a/lib_pypy/_tkinter/tclobj.py
+++ b/lib_pypy/_tkinter/tclobj.py
@@ -11,7 +11,7 @@
self.ListType = tklib.Tcl_GetObjType("list")
self.ProcBodyType = tklib.Tcl_GetObjType("procbody")
self.StringType = tklib.Tcl_GetObjType("string")
-
+
def FromObj(app, value):
"""Convert a TclObj pointer into a Python object."""
@@ -24,7 +24,14 @@
try:
result.decode('ascii')
except UnicodeDecodeError:
- result = result.decode('utf8')
+ try:
+ result = result.decode('utf8')
+ except UnicodeDecodeError:
+ # Tcl encodes null character as \xc0\x80
+ try:
+ result = result.replace('\xc0\x80', '\x00').decode('utf-8')
+ except UnicodeDecodeError:
+ pass
return result
elif value.typePtr == typeCache.BooleanType:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit