[pypy-commit] pypy py3.5: Fix test_tcl
amauryfa
pypy.commits at gmail.com
Tue Nov 8 02:55:23 EST 2016
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3.5
Changeset: r88196:dd00f854111a
Date: 2016-11-07 21:41 +0100
http://bitbucket.org/pypy/pypy/changeset/dd00f854111a/
Log: Fix test_tcl
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
@@ -359,7 +359,7 @@
for i in range(objc[0]):
result.append(FromObj(self, objv[0][i]))
return tuple(result)
- elif isinstance(arg, tuple):
+ elif isinstance(arg, (tuple, list)):
return self._splitObj(arg)
if isinstance(arg, str):
arg = arg.encode('utf-8')
@@ -378,6 +378,8 @@
return tuple(result)
elif isinstance(arg, tuple):
return arg
+ elif isinstance(arg, list):
+ return tuple(arg)
elif isinstance(arg, str):
arg = arg.encode('utf8')
@@ -411,6 +413,9 @@
result[i] = newelem
if result is not None:
return tuple(result)
+ if isinstance(arg, list):
+ # Recursively invoke SplitObj for all list items.
+ return tuple(self._splitObj(elem) for elem in arg)
elif isinstance(arg, str):
argc = tkffi.new("int*")
argv = tkffi.new("char***")
@@ -483,7 +488,10 @@
def getboolean(self, s):
if isinstance(s, int):
return bool(s)
- s = s.encode('utf-8')
+ try:
+ s = s.encode('utf-8')
+ except AttributeError:
+ raise TypeError
if b'\x00' in s:
raise TypeError
v = tkffi.new("int*")
@@ -493,9 +501,12 @@
return bool(v[0])
def getint(self, s):
- if isinstance(s, (int, long)):
+ if isinstance(s, int):
return s
- s = s.encode('utf-8')
+ try:
+ s = s.encode('utf-8')
+ except AttributeError:
+ raise TypeError
if b'\x00' in s:
raise TypeError
if tklib.HAVE_LIBTOMMATH or tklib.HAVE_WIDE_INT_TYPE:
@@ -517,11 +528,14 @@
return v[0]
def getdouble(self, s):
- if isinstance(s, float):
- return s
- if '\x00' in s:
+ if isinstance(s, (float, int)):
+ return float(s)
+ try:
+ s = s.encode('utf-8')
+ except AttributeError:
raise TypeError
- s = s.encode('utf-8')
+ if b'\x00' in s:
+ raise TypeError
v = tkffi.new("double*")
res = tklib.Tcl_GetDouble(self.interp, s, v)
if res == tklib.TCL_ERROR:
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
@@ -70,7 +70,7 @@
def AsBignumObj(value):
sign = -1 if value < 0 else 1
- hexstr = '%x' % abs(value)
+ hexstr = b'%x' % abs(value)
bigValue = tkffi.new("mp_int*")
tklib.mp_init(bigValue)
try:
@@ -133,7 +133,7 @@
def AsObj(value):
if isinstance(value, bytes):
- return tklib.Tcl_NewStringObj(value, len(value))
+ return tklib.Tcl_NewByteArrayObj(value, len(value))
if isinstance(value, bool):
return tklib.Tcl_NewBooleanObj(value)
if isinstance(value, int):
@@ -151,7 +151,7 @@
return AsBignumObj(value)
if isinstance(value, float):
return tklib.Tcl_NewDoubleObj(value)
- if isinstance(value, tuple):
+ if isinstance(value, (tuple, list)):
argv = tkffi.new("Tcl_Obj*[]", len(value))
for i in range(len(value)):
argv[i] = AsObj(value[i])
More information about the pypy-commit
mailing list