Commits

Hakan Ardo committed 10d0ddb Merge

hg merge

Comments (0)

Files changed (7)

pypy/jit/metainterp/test/test_virtual.py

         
         def f():
             i = 0
-            s = 0
+            s = 10000
             a = A("data")
             while i < 10:
                 mydriver.jit_merge_point(i=i, a=a, s=s)
                 if i > 1:
                     if a.state == 'data':
                         a.state = 'escaped'
+                        s += 1000
                     else:
-                        s += 1
+                        s += 100
+                else:
+                    s += 10
+                i += 1
+            return s
+
+        res = self.meta_interp(f, [], repeat=7)
+        assert res == f()
+
+    def test_getfield_gc_pure_nobug(self):
+        mydriver = JitDriver(reds = ['i', 's', 'a'], greens = [])
+
+        class A(object):
+            _immutable_fields_ = ['foo']
+            def __init__(self, foo):
+                self.foo = foo
+
+        prebuilt42 = A(42)
+        prebuilt43 = A(43)
+
+        def f():
+            i = 0
+            s = 10000
+            a = prebuilt42
+            while i < 10:
+                mydriver.jit_merge_point(i=i, s=s, a=a)
+                if i > 1:
+                    s += a.foo
+                    a = prebuilt43
+                else:
+                    s += 10
                 i += 1
             return s
 

pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py

         jump(p0, p1, p2, i12, p4, descr=<Loop0>)
         """)
 
+    def test_exception_inside_loop_2(self):
+        def main(n):
+            def g(n):
+                raise ValueError(n)  # ID: raise
+            def f(n):
+                g(n)
+            #
+            while n:
+                try:
+                    f(n)
+                except ValueError:
+                    pass
+                n -= 1
+            return n
+        #
+        log = self.run(main, [1000], threshold=400)
+        assert log.result == 0
+        loop, = log.loops_by_filename(self.filepath)
+        ops = log.opnames(loop.ops_by_id('raise'))
+        assert 'new' not in ops
+
     def test_reraise(self):
         def f(n):
             i = 0
         log = self.run(f, [100000])
         assert log.result == 100000
         loop, = log.loops_by_filename(self.filepath)
+        assert loop.match("""
+            i7 = int_lt(i4, i5)
+            guard_true(i7, descr=<Guard3>)
+            --EXC-TICK--
+            i14 = int_add(i4, 1)
+            --TICK--
+            jump(p0, p1, p2, p3, i14, i5, p6, descr=<Loop0>)
+        """)

pypy/objspace/std/objecttype.py

     return w_obj
 
 def descr__init__(space, w_obj, __args__):
-    pass
+    w_type = space.type(w_obj)
+    w_parent_new, _ = w_type.lookup_where('__new__')
+    w_parent_init, _ = w_type.lookup_where('__init__')
+    try:
+        __args__.fixedunpack(0)
+    except ValueError:
+        if w_parent_new is not space.w_object and w_parent_init is not space.w_object:
+            space.warn("object.__init__() takes no parameters", space.w_DeprecationWarning)
+        elif w_parent_new is space.w_object or w_parent_init is not space.w_object:
+            raise OperationError(space.w_TypeError,
+                space.wrap("object.__init__() takes no parameters")
+            )
+
+
 
 @gateway.unwrap_spec(proto=int)
 def descr__reduce__(space, w_obj, proto=0):

pypy/objspace/std/test/test_obj.py

+from __future__ import with_statement
 from pypy.conftest import option
 
 class AppTestObject:
         import sys
         cpython_behavior = (not option.runappdirect
                             or not hasattr(sys, 'pypy_translation_info'))
-                
+
         cls.w_cpython_behavior = cls.space.wrap(cpython_behavior)
         cls.w_cpython_version = cls.space.wrap(tuple(sys.version_info))
-    
+
     def test_hash_builtin(self):
         if not self.cpython_behavior:
             skip("on pypy-c id == hash is not guaranteed")
 
     def test_hash_method(self):
         o = object()
-        assert hash(o) == o.__hash__() 
+        assert hash(o) == o.__hash__()
 
     def test_hash_list(self):
         l = range(5)
             pass
         assert x().__subclasshook__(object()) is NotImplemented
         assert x.__subclasshook__(object()) is NotImplemented
+
+    def test_object_init(self):
+        import warnings
+
+        class A(object):
+            pass
+
+        raises(TypeError, A().__init__, 3)
+        raises(TypeError, A().__init__, a=3)
+
+        class B(object):
+            def __new__(cls):
+                return super(B, cls).__new__(cls)
+
+            def __init__(self):
+                super(B, self).__init__(a=3)
+
+        with warnings.catch_warnings(record=True) as log:
+            warnings.simplefilter("always", DeprecationWarning)
+            B()
+        assert len(log) == 1
+        assert log[0].message.args == ("object.__init__() takes no parameters",)
+        assert type(log[0].message) is DeprecationWarning

pypy/rpython/lltypesystem/rffi.py

             data_start = cast_ptr_to_adr(llstrtype(data)) + \
                 offsetof(STRTYPE, 'chars') + itemoffsetof(STRTYPE.chars, 0)
             return cast(TYPEP, data_start)
+    get_nonmovingbuffer._annenforceargs_ = [strtype]
 
     # (str, char*) -> None
     def free_nonmovingbuffer(data, buf):
         keepalive_until_here(data)
         if not followed_2nd_path:
             lltype.free(buf, flavor='raw')
+    free_nonmovingbuffer._annenforceargs_ = [strtype, None]
 
     # int -> (char*, str)
     def alloc_buffer(count):
         raw_buf = lltype.malloc(TYPEP.TO, count, flavor='raw')
         return raw_buf, lltype.nullptr(STRTYPE)
     alloc_buffer._always_inline_ = True # to get rid of the returned tuple
+    alloc_buffer._annenforceargs_ = [int]
 
     # (char*, str, int, int) -> None
     def str_from_buffer(raw_buf, gc_buf, allocated_size, needed_size):

pypy/tool/jitlogparser/parser.py

     # factory method
     TraceForOpcode = TraceForOpcode
 
-    def __init__(self, chunks, path, storage, inputargs):
+    def __init__(self, chunks, path, storage, inputargs=''):
         self.path = path
         self.inputargs = inputargs
         self.chunks = chunks

pypy/translator/platform/posix.py

             ('CFLAGS', cflags),
             ('CFLAGSEXTRA', list(eci.compile_extra)),
             ('LDFLAGS', linkflags),
+            ('LDFLAGS_LINK', list(self.link_flags)),
             ('LDFLAGSEXTRA', list(eci.link_extra)),
             ('CC', self.cc),
             ('CC_LINK', eci.use_cpp_linker and 'g++' or '$(CC)'),
                    'int main(int argc, char* argv[]) '
                    '{ return $(PYPY_MAIN_FUNCTION)(argc, argv); }" > $@')
             m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.o'],
-                   '$(CC_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@')
+                   '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@')
 
         return m