Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r73128:e8ec916b9a16 Date: 2014-08-28 15:52 -0700 http://bitbucket.org/pypy/pypy/changeset/e8ec916b9a16/
Log: adapt to py3 diff --git a/lib_pypy/_tkinter/app.py b/lib_pypy/_tkinter/app.py --- a/lib_pypy/_tkinter/app.py +++ b/lib_pypy/_tkinter/app.py @@ -450,8 +450,7 @@ def getint(self, s): if isinstance(s, int): return s - if isinstance(s, unicode): - s = str(s) + s = s.encode('utf-8') if '\x00' in s: raise TypeError v = tkffi.new("int*") @@ -463,8 +462,7 @@ def getdouble(self, s): if isinstance(s, float): return s - if isinstance(s, unicode): - s = str(s) + s = s.encode('utf-8') if '\x00' in s: raise TypeError v = tkffi.new("double*") 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 @@ -14,19 +14,14 @@ def FromTclString(s): - # If the result contains any bytes with the top bit set, it's - # UTF-8 and we should decode it to Unicode. try: - s.decode('ascii') + return s.decode('utf8') except UnicodeDecodeError: + # Tcl encodes null character as \xc0\x80 try: - return s.decode('utf8') + return s.replace('\xc0\x80', '\x00').decode('utf-8') except UnicodeDecodeError: - # Tcl encodes null character as \xc0\x80 - try: - return s.replace('\xc0\x80', '\x00').decode('utf-8') - except UnicodeDecodeError: - pass + pass return s _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit