[pypy-commit] pypy default: merged upstream

alex_gaynor noreply at buildbot.pypy.org
Fri Jul 12 01:20:49 CEST 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r65361:4f246f62b2ef
Date: 2013-07-12 09:19 +1000
http://bitbucket.org/pypy/pypy/changeset/4f246f62b2ef/

Log:	merged upstream

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -12,3 +12,7 @@
 .. branch: improve-str2charp
 Improve the performance of I/O writing up to 15% by using memcpy instead of
 copying char-by-char in str2charp and get_nonmovingbuffer
+
+.. branch: flowoperators
+Simplify rpython/flowspace/ code by using more metaprogramming.  Create
+SpaceOperator class to gather static information about flow graph operations.
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -371,7 +371,7 @@
         from pypy.module._pickle_support import maker # helper fns
         from pypy.interpreter.pycode import PyCode
         from pypy.interpreter.module import Module
-        args_w = space.unpackiterable(w_args)
+        args_w = space.unpackiterable(w_args, 18)
         w_f_back, w_builtin, w_pycode, w_valuestack, w_blockstack, w_exc_value, w_tb,\
             w_globals, w_last_instr, w_finished, w_f_lineno, w_fastlocals, w_f_locals, \
             w_f_trace, w_instr_lb, w_instr_ub, w_instr_prev_plus_one, w_cells = args_w
diff --git a/pypy/interpreter/test/test_zzpickle_and_slow.py b/pypy/interpreter/test/test_zzpickle_and_slow.py
--- a/pypy/interpreter/test/test_zzpickle_and_slow.py
+++ b/pypy/interpreter/test/test_zzpickle_and_slow.py
@@ -226,6 +226,10 @@
         restore_top_frame(f1, saved) 
         f2     = pickle.loads(pckl)
 
+    def test_frame_setstate_crash(self):
+        import sys
+        raises(ValueError, sys._getframe().__setstate__, [])
+
     def test_pickle_traceback(self):
         def f():
             try:
diff --git a/pypy/module/_rawffi/test/test__rawffi.py b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -1107,6 +1107,14 @@
         S2E = _rawffi.Structure([('bah', (EMPTY, 1))])
         S2E.get_ffi_type()     # does not hang
 
+    def test_overflow_error(self):
+        import _rawffi
+        A = _rawffi.Array('d')
+        arg1 = A(1)
+        raises(OverflowError, "arg1[0] = 10**900")
+        arg1.free()
+
+
 class AppTestAutoFree:
     spaceconfig = dict(usemodules=['_rawffi', 'struct'])
 
diff --git a/pypy/module/_socket/interp_socket.py b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -473,7 +473,7 @@
                     option_ptr = rffi.cast(rffi.INTP, value_ptr)
                     option_ptr[0] = space.int_w(w_option)
                 elif cmd == _c.SIO_KEEPALIVE_VALS:
-                    w_onoff, w_time, w_interval = space.unpackiterable(w_option)
+                    w_onoff, w_time, w_interval = space.unpackiterable(w_option, 3)
                     option_ptr = rffi.cast(lltype.Ptr(_c.tcp_keepalive), value_ptr)
                     option_ptr.c_onoff = space.uint_w(w_onoff)
                     option_ptr.c_keepalivetime = space.uint_w(w_time)
diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -74,7 +74,7 @@
     return space.newtuple([w_fileobj, w_filename, w_import_info])
 
 def load_module(space, w_name, w_file, w_filename, w_info):
-    w_suffix, w_filemode, w_modtype = space.unpackiterable(w_info)
+    w_suffix, w_filemode, w_modtype = space.unpackiterable(w_info, 3)
 
     filename = space.str0_w(w_filename)
     filemode = space.str_w(w_filemode)
diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -679,6 +679,10 @@
         assert module.__name__ == 'a'
         assert module.__file__ == 'invalid_path_name'
 
+    def test_crash_load_module(self):
+        import imp
+        raises(ValueError, imp.load_module, "", "", "", [1, 2, 3, 4])
+
 
 class TestAbi:
     def test_abi_tag(self):
diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -318,7 +318,7 @@
             if not base.issequence_w(space, w_shape):
                 w_shape = space.newtuple([w_shape,])
         else:
-            w_fldname, w_flddesc = space.fixedview(w_elem)
+            w_fldname, w_flddesc = space.fixedview(w_elem, 2)
         subdtype = descr__new__(space, space.gettypefor(W_Dtype), w_flddesc, w_shape=w_shape)
         fldname = space.str_w(w_fldname)
         if fldname in fields:
diff --git a/pypy/module/rctime/test/test_rctime.py b/pypy/module/rctime/test/test_rctime.py
--- a/pypy/module/rctime/test/test_rctime.py
+++ b/pypy/module/rctime/test/test_rctime.py
@@ -43,6 +43,7 @@
         assert isinstance(res, str)
         rctime.ctime(rctime.time())
         raises(ValueError, rctime.ctime, 1E200)
+        raises(OverflowError, rctime.ctime, 10**900)
 
     def test_gmtime(self):
         import time as rctime
diff --git a/pypy/objspace/std/complexobject.py b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -126,10 +126,7 @@
     return W_ComplexObject(w_int.intval, 0.0)
 
 def delegate_Long2Complex(space, w_long):
-    try:
-        dval =  w_long.tofloat()
-    except OverflowError, e:
-        raise OperationError(space.w_OverflowError, space.wrap(str(e)))
+    dval = w_long.tofloat(space)
     return W_ComplexObject(dval, 0.0)
 
 def delegate_Float2Complex(space, w_float):
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1039,15 +1039,18 @@
 
 
 def update1(space, w_dict, w_data):
-    if space.findattr(w_data, space.wrap("keys")) is None:
+    if isinstance(w_data, W_DictMultiObject):    # optimization case only
+        update1_dict_dict(space, w_dict, w_data)
+        return
+    w_method = space.findattr(w_data, space.wrap("keys"))
+    if w_method is None:
         # no 'keys' method, so we assume it is a sequence of pairs
-        update1_pairs(space, w_dict, w_data)
+        data_w = space.listview(w_data)
+        update1_pairs(space, w_dict, data_w)
     else:
-        if isinstance(w_data, W_DictMultiObject):    # optimization case only
-            update1_dict_dict(space, w_dict, w_data)
-        else:
-            # general case -- "for k in o.keys(): dict.__setitem__(d, k, o[k])"
-            update1_keys(space, w_dict, w_data)
+        # general case -- "for k in o.keys(): dict.__setitem__(d, k, o[k])"
+        data_w = space.listview(space.call_function(w_method))
+        update1_keys(space, w_dict, w_data, data_w)
 
 
 @jit.look_inside_iff(lambda space, w_dict, w_data:
@@ -1061,8 +1064,8 @@
         w_dict.setitem(w_key, w_value)
 
 
-def update1_pairs(space, w_dict, w_data):
-    for w_pair in space.listview(w_data):
+def update1_pairs(space, w_dict, data_w):
+    for w_pair in data_w:
         pair = space.fixedview(w_pair)
         if len(pair) != 2:
             raise OperationError(space.w_ValueError,
@@ -1071,9 +1074,8 @@
         w_dict.setitem(w_key, w_value)
 
 
-def update1_keys(space, w_dict, w_data):
-    w_keys = space.call_method(w_data, "keys")
-    for w_key in space.listview(w_keys):
+def update1_keys(space, w_dict, w_data, data_w):
+    for w_key in data_w:
         w_value = space.getitem(w_data, w_key)
         w_dict.setitem(w_key, w_value)
 
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -62,11 +62,7 @@
 
 # long-to-float delegation
 def delegate_Long2Float(space, w_longobj):
-    try:
-        return W_FloatObject(w_longobj.tofloat())
-    except OverflowError:
-        raise OperationError(space.w_OverflowError,
-                             space.wrap("long int too large to convert to float"))
+    return W_FloatObject(w_longobj.tofloat(space))
 
 
 # float__Float is supposed to do nothing, unless it has
diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -26,8 +26,12 @@
     def longval(self):
         return self.num.tolong()
 
-    def tofloat(self):
-        return self.num.tofloat()
+    def tofloat(self, space):
+        try:
+            return self.num.tofloat()
+        except OverflowError:
+            raise OperationError(space.w_OverflowError,
+                    space.wrap("long int too large to convert to float"))
 
     def toint(self):
         return self.num.toint()
@@ -66,7 +70,7 @@
         return w_self.num
 
     def float_w(self, space):
-        return self.num.tofloat()
+        return self.tofloat(space)
 
     def int(self, space):
         if (type(self) is not W_LongObject and
@@ -124,11 +128,7 @@
     return long__Long(space, w_value)
 
 def float__Long(space, w_longobj):
-    try:
-        return space.newfloat(w_longobj.num.tofloat())
-    except OverflowError:
-        raise OperationError(space.w_OverflowError,
-                             space.wrap("long int too large to convert to float"))
+    return space.newfloat(w_longobj.tofloat(space))
 
 def repr__Long(space, w_long):
     return space.wrap(w_long.num.repr())
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -180,8 +180,7 @@
         if not space.isinstance_w(w_other, space.w_set):
             return space.w_False
 
-        # XXX there is no test_buildinshortcut.py
-        # tested in test_buildinshortcut.py
+        # tested in test_builtinshortcut.py
         # XXX do not make new setobject here
         w_other_as_set = self._newobj(space, w_other)
         return space.wrap(self.equals(w_other_as_set))
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -367,6 +367,16 @@
         d.update({'foo': 'bar'}, baz=1)
         assert d == {'foo': 'bar', 'baz': 1}
 
+    def test_update_keys_method(self):
+        class Foo(object):
+            def keys(self):
+                return [4, 1]
+            def __getitem__(self, key):
+                return key * 10
+        d = {}
+        d.update(Foo())
+        assert d == {1: 10, 4: 40}
+
     def test_values(self):
         d = {1: 2, 3: 4}
         vals = d.values()
diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -18,6 +18,12 @@
         w_obj = fromlong(42)
         assert space.unwrap(w_obj) == 42
 
+    def test_overflow_error(self):
+        space = self.space
+        fromlong = lobj.W_LongObject.fromlong
+        w_big = fromlong(10**900)
+        space.raises_w(space.w_OverflowError, space.float_w, w_big)
+
     def test_rint_variants(self):
         py.test.skip("XXX broken!")
         from rpython.rtyper.tool.rfficache import platform


More information about the pypy-commit mailing list