[pypy-commit] pypy py3k: merge heads
antocuni
noreply at buildbot.pypy.org
Thu Oct 18 14:23:44 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r58209:5a77344eeda8
Date: 2012-10-18 14:23 +0200
http://bitbucket.org/pypy/pypy/changeset/5a77344eeda8/
Log: merge heads
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -852,7 +852,8 @@
def _getdefaults(self, space):
"NOT_RPYTHON"
defs_w = []
- for name, defaultval in self._staticdefs:
+ unwrap_spec = self._code._unwrap_spec[-len(self._staticdefs):]
+ for i, (name, defaultval) in enumerate(self._staticdefs):
if name.startswith('w_'):
assert defaultval is None, (
"%s: default value for '%s' can only be None; "
@@ -860,7 +861,11 @@
self._code.identifier, name))
defs_w.append(None)
else:
- defs_w.append(space.wrap(defaultval))
+ spec = unwrap_spec[i]
+ if isinstance(defaultval, str) and spec not in [str]:
+ defs_w.append(space.wrapbytes(defaultval))
+ else:
+ defs_w.append(space.wrap(defaultval))
if self._code._unwrap_spec:
UNDEFINED = object()
alldefs_w = [UNDEFINED] * len(self._code.sig[0])
diff --git a/pypy/interpreter/test/test_gateway.py b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -611,6 +611,16 @@
never_called
py.test.raises(AssertionError, space.wrap, gateway.interp2app_temp(g))
+ def test_unwrap_spec_default_bytes(self):
+ space = self.space
+ @gateway.unwrap_spec(s='bufferstr')
+ def g(space, s=''):
+ return space.wrap(type(s) is str)
+ w_g = space.wrap(gateway.interp2app_temp(g))
+ args = argument.Arguments(space, [])
+ w_res = space.call_args(w_g, args)
+ assert space.eq_w(w_res, space.w_True)
+
def test_unwrap_spec_default_applevel_bytes(self):
space = self.space
@gateway.unwrap_spec(w_x=WrappedDefault('foo'))
diff --git a/pypy/module/_collections/test/test_deque.py b/pypy/module/_collections/test/test_deque.py
--- a/pypy/module/_collections/test/test_deque.py
+++ b/pypy/module/_collections/test/test_deque.py
@@ -171,7 +171,7 @@
assert list(d) == list(reversed(range(1000, 1200)))
#
n = 100
- data = map(str, range(n))
+ data = list(map(str, range(n)))
for i in range(n):
d = deque(data[:i])
r = d.reverse()
diff --git a/pypy/objspace/std/specialisedtupleobject.py b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -188,15 +188,26 @@
Cls_ff = make_specialised_class((float, float))
#Cls_ooo = make_specialised_class((object, object, object))
+def is_int_w(space, w_obj):
+ """Determine if obj can be safely casted to an int_w"""
+ try:
+ space.int_w(w_obj)
+ except OperationError, e:
+ if not (e.match(space, space.w_OverflowError) or
+ e.match(space, space.w_TypeError)):
+ raise
+ return False
+ return True
+
def makespecialisedtuple(space, list_w):
if len(list_w) == 2:
w_arg1, w_arg2 = list_w
w_type1 = space.type(w_arg1)
#w_type2 = space.type(w_arg2)
#
- if w_type1 is space.w_int:
+ if w_type1 is space.w_int and is_int_w(space, w_arg1):
w_type2 = space.type(w_arg2)
- if w_type2 is space.w_int:
+ if w_type2 is space.w_int and is_int_w(space, w_arg2):
return Cls_ii(space, w_arg1, w_arg2)
#elif w_type2 is space.w_str:
# return Cls_is(space, w_arg1, w_arg2)
diff --git a/pypy/objspace/std/test/test_specialisedtupleobject.py b/pypy/objspace/std/test/test_specialisedtupleobject.py
--- a/pypy/objspace/std/test/test_specialisedtupleobject.py
+++ b/pypy/objspace/std/test/test_specialisedtupleobject.py
@@ -243,6 +243,10 @@
assert a == (1, 2.2,) + b
assert not a != (1, 2.2) + b
+ def test_ovfl_bug(self):
+ # previously failed
+ a = (0xffffffffffffffff, 0)
+
class AppTestAll(test_tupleobject.AppTestW_TupleObject):
pass
More information about the pypy-commit
mailing list