Author: Manuel Jacob <m...@manueljacob.de>
Branch: improve-docs
Changeset: r72743:08ba84b1fa90
Date: 2014-08-09 23:04 +0200
http://bitbucket.org/pypy/pypy/changeset/08ba84b1fa90/

Log:    hg merge default

diff --git a/include/PyPy.h b/include/PyPy.h
--- a/include/PyPy.h
+++ b/include/PyPy.h
@@ -53,6 +53,12 @@
 int pypy_execute_source_ptr(char *source, void* ptr);
 
 
+/* Windows hackery */
+#if defined(_MSC_VER)
+#  pragma comment(lib,"python27.lib")
+#endif
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib_pypy/cffi.egg-info b/lib_pypy/cffi.egg-info
--- a/lib_pypy/cffi.egg-info
+++ b/lib_pypy/cffi.egg-info
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: cffi
-Version: 0.8
+Version: 0.8.6
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
diff --git a/pypy/doc/getting-started-python.rst 
b/pypy/doc/getting-started-python.rst
deleted file mode 100644
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -616,7 +616,8 @@
     def descr_classmethod_get(self, space, w_obj, w_klass=None):
         if space.is_none(w_klass):
             w_klass = space.type(w_obj)
-        return space.wrap(Method(space, self.w_function, w_klass, 
space.w_None))
+        return space.wrap(Method(space, self.w_function, w_klass,
+                                 space.type(w_klass)))
 
     def descr_classmethod__new__(space, w_subtype, w_function):
         instance = space.allocate_instance(ClassMethod, w_subtype)
diff --git a/pypy/interpreter/pycompiler.py b/pypy/interpreter/pycompiler.py
--- a/pypy/interpreter/pycompiler.py
+++ b/pypy/interpreter/pycompiler.py
@@ -96,7 +96,7 @@
 
     XXX: This class should override the baseclass implementation of
          compile_command() in order to optimize it, especially in case
-         of incomplete inputs (e.g. we shouldn't re-compile from sracth
+         of incomplete inputs (e.g. we shouldn't re-compile from scratch
          the whole source after having only added a new '\n')
     """
     def __init__(self, space, override_version=None):
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -61,6 +61,7 @@
             while True:
                 next_instr = self.handle_bytecode(co_code, next_instr, ec)
         except ExitFrame:
+            self.last_exception = None
             return self.popvalue()
 
     def handle_bytecode(self, co_code, next_instr, ec):
diff --git a/pypy/interpreter/test/test_generator.py 
b/pypy/interpreter/test/test_generator.py
--- a/pypy/interpreter/test/test_generator.py
+++ b/pypy/interpreter/test/test_generator.py
@@ -280,6 +280,20 @@
             raise StopIteration
         assert tuple(f()) == (1,)
 
+    def test_exception_is_cleared_by_yield(self):
+        def f():
+            try:
+                foobar
+            except NameError:
+                yield 5
+                raise    # should raise "no active exception to re-raise"
+        gen = f()
+        gen.next()  # --> 5
+        try:
+            gen.next()
+        except TypeError:
+            pass
+
 
 def test_should_not_inline(space):
     from pypy.interpreter.generator import should_not_inline
diff --git a/pypy/interpreter/test/test_typedef.py 
b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -388,6 +388,13 @@
         # differs from .im_class in case the method is
         # defined in some parent class of l's actual class
 
+    def test_classmethod_im_class(self):
+        class Foo(object):
+            @classmethod
+            def bar(cls):
+                pass
+        assert Foo.bar.im_class is type
+
     def test_func_closure(self):
         x = 2
         def f():
diff --git a/pypy/module/__builtin__/app_inspect.py 
b/pypy/module/__builtin__/app_inspect.py
--- a/pypy/module/__builtin__/app_inspect.py
+++ b/pypy/module/__builtin__/app_inspect.py
@@ -7,8 +7,8 @@
 
 from __pypy__ import lookup_special
 
-def _caller_locals(): 
-    return sys._getframe(0).f_locals 
+def _caller_locals():
+    return sys._getframe(0).f_locals
 
 def vars(*obj):
     """Return a dictionary of all the attributes currently bound in obj.  If
@@ -17,12 +17,11 @@
     if len(obj) == 0:
         return _caller_locals()
     elif len(obj) != 1:
-        raise TypeError, "vars() takes at most 1 argument."
-    else:
-        try:
-            return obj[0].__dict__
-        except AttributeError:
-            raise TypeError, "vars() argument must have __dict__ attribute"
+        raise TypeError("vars() takes at most 1 argument.")
+    try:
+        return obj[0].__dict__
+    except AttributeError:
+        raise TypeError("vars() argument must have __dict__ attribute")
 
 def dir(*args):
     """dir([object]) -> list of strings
@@ -38,8 +37,7 @@
         attributes of its class's base classes.
     """
     if len(args) > 1:
-        raise TypeError("dir expected at most 1 arguments, got %d"
-                        % len(args))
+        raise TypeError("dir expected at most 1 arguments, got %d" % len(args))
     if len(args) == 0:
         local_names = _caller_locals().keys() # 2 stackframes away
         if not isinstance(local_names, list):
@@ -48,92 +46,61 @@
         return local_names
 
     import types
-
     obj = args[0]
-
-    dir_meth = None
     if isinstance(obj, types.InstanceType):
-        try:
-            dir_meth = getattr(obj, "__dir__")
-        except AttributeError:
-            pass
+        dir_meth = getattr(obj, '__dir__', None)
     else:
-        dir_meth = lookup_special(obj, "__dir__")
+        dir_meth = lookup_special(obj, '__dir__')
     if dir_meth is not None:
-        result = dir_meth()
-        if not isinstance(result, list):
+        names = dir_meth()
+        if not isinstance(names, list):
             raise TypeError("__dir__() must return a list, not %r" % (
-                type(result),))
-        result.sort()
-        return result
+                type(names),))
+        names.sort()
+        return names
     elif isinstance(obj, types.ModuleType):
         try:
-            result = list(obj.__dict__)
-            result.sort()
-            return result
+            return sorted(obj.__dict__)
         except AttributeError:
             return []
-
     elif isinstance(obj, (types.TypeType, types.ClassType)):
-        #Don't look at __class__, as metaclass methods would be confusing.
-        result = _classdir(obj).keys()
-        result.sort()
-        return result
-
-    else: #(regular item)
-        Dict = {}
-        try:
-            if isinstance(obj.__dict__, dict):
-                Dict.update(obj.__dict__)
-        except AttributeError:
-            pass
-        try:
-            Dict.update(_classdir(obj.__class__))
-        except AttributeError:
-            pass
+        # Don't look at __class__, as metaclass methods would be confusing.
+        return sorted(_classdir(obj))
+    else:
+        names = set()
+        ns = getattr(obj, '__dict__', None)
+        if isinstance(ns, dict):
+            names.update(ns)
+        klass = getattr(obj, '__class__', None)
+        if klass is not None:
+            names.update(_classdir(klass))
 
         ## Comment from object.c:
         ## /* Merge in __members__ and __methods__ (if any).
         ## XXX Would like this to go away someday; for now, it's
         ## XXX needed to get at im_self etc of method objects. */
-        for attr in ['__members__','__methods__']:
-            try:
-                l = getattr(obj, attr)
-                if not isinstance(l, list):
-                    continue
-                for item in l:
-                    if isinstance(item, types.StringTypes):
-                        Dict[item] = None
-            except (AttributeError, TypeError):
-                pass
+        for attr in '__members__', '__methods__':
+            l = getattr(obj, attr, None)
+            if not isinstance(l, list):
+                continue
+            names.extend(item for item in l if isinstance(item, str))
 
-        result = Dict.keys()
-        result.sort()
-        return result
+        return sorted(names)
 
 def _classdir(klass):
-    """Return a dict of the accessible attributes of class/type klass.
+    """Return a set of the accessible attributes of class/type klass.
 
-    This includes all attributes of klass and all of the
-    base classes recursively.
-
-    The values of this dict have no meaning - only the keys have
-    meaning.  
+    This includes all attributes of klass and all of the base classes
+    recursively.
     """
-    Dict = {}
-    try:
-        Dict.update(klass.__dict__)
-    except AttributeError: pass 
-    try:
-        # XXX - Use of .__mro__ would be suggested, if the existance
-        #   of that attribute could be guarranted.
-        bases = klass.__bases__
-    except AttributeError: pass
-    else:
-        try:
-            #Note that since we are only interested in the keys,
-            #  the order we merge classes is unimportant
-            for base in bases:
-                Dict.update(_classdir(base))
-        except TypeError: pass
-    return Dict
+    names = set()
+    ns = getattr(klass, '__dict__', None)
+    if ns is not None:
+        names.update(ns)
+    bases = getattr(klass, '__bases__', None)
+    if bases is not None:
+        # Note that since we are only interested in the keys, the order
+        # we merge classes is unimportant
+        for base in bases:
+            names.update(_classdir(base))
+    return names
diff --git a/pypy/module/_io/interp_bytesio.py 
b/pypy/module/_io/interp_bytesio.py
--- a/pypy/module/_io/interp_bytesio.py
+++ b/pypy/module/_io/interp_bytesio.py
@@ -4,12 +4,15 @@
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from rpython.rlib.rStringIO import RStringIO
 from rpython.rlib.rarithmetic import r_longlong
+from rpython.rlib.objectmodel import import_from_mixin
 from pypy.module._io.interp_bufferedio import W_BufferedIOBase
 from pypy.module._io.interp_iobase import convert_size
 import sys
 
 
-class W_BytesIO(RStringIO, W_BufferedIOBase):
+class W_BytesIO(W_BufferedIOBase):
+    import_from_mixin(RStringIO)
+
     def __init__(self, space):
         W_BufferedIOBase.__init__(self, space, add_to_autoflusher=False)
         self.init()
diff --git a/pypy/module/_md5/interp_md5.py b/pypy/module/_md5/interp_md5.py
--- a/pypy/module/_md5/interp_md5.py
+++ b/pypy/module/_md5/interp_md5.py
@@ -1,13 +1,15 @@
 from rpython.rlib import rmd5
+from rpython.rlib.objectmodel import import_from_mixin
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.typedef import TypeDef
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 
 
-class W_MD5(W_Root, rmd5.RMD5):
+class W_MD5(W_Root):
     """
     A subclass of RMD5 that can be exposed to app-level.
     """
+    import_from_mixin(rmd5.RMD5)
 
     def __init__(self, space):
         self.space = space
diff --git a/pypy/module/_sha/interp_sha.py b/pypy/module/_sha/interp_sha.py
--- a/pypy/module/_sha/interp_sha.py
+++ b/pypy/module/_sha/interp_sha.py
@@ -1,13 +1,15 @@
 from rpython.rlib import rsha
+from rpython.rlib.objectmodel import import_from_mixin
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.typedef import TypeDef
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 
 
-class W_SHA(W_Root, rsha.RSHA):
+class W_SHA(W_Root):
     """
     A subclass of RSHA that can be exposed to app-level.
     """
+    import_from_mixin(rsha.RSHA)
 
     def __init__(self, space):
         self.space = space
diff --git a/pypy/module/cStringIO/interp_stringio.py 
b/pypy/module/cStringIO/interp_stringio.py
--- a/pypy/module/cStringIO/interp_stringio.py
+++ b/pypy/module/cStringIO/interp_stringio.py
@@ -3,6 +3,7 @@
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from rpython.rlib.rStringIO import RStringIO
+from rpython.rlib.objectmodel import import_from_mixin
 
 
 class W_InputOutputType(W_Root):
@@ -144,7 +145,9 @@
 
 # ____________________________________________________________
 
-class W_OutputType(RStringIO, W_InputOutputType):
+class W_OutputType(W_InputOutputType):
+    import_from_mixin(RStringIO)
+
     def __init__(self, space):
         self.init()
         self.space = space
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py 
b/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py
@@ -0,0 +1,12 @@
+from email.parser import Parser
+
+import py
+
+import cffi
+import pypy
+
+egg_info = py.path.local(pypy.__file__) / '../../lib_pypy/cffi.egg-info'
+
+def test_egg_version():
+    info = Parser().parsestr(egg_info.read())
+    assert info['version'] == cffi.__version__
diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py
--- a/pypy/objspace/std/iterobject.py
+++ b/pypy/objspace/std/iterobject.py
@@ -30,10 +30,6 @@
         raise NotImplementedError
 
     def descr_reduce(self, space):
-        """
-        XXX to do: remove this __reduce__ method and do
-        a registration with copy_reg, instead.
-        """
         from pypy.interpreter.mixedmodule import MixedModule
         w_mod = space.getbuiltinmodule('_pickle_support')
         mod = space.interp_w(MixedModule, w_mod)
@@ -125,10 +121,6 @@
         self.index = space.int_w(self.w_len) + index
 
     def descr_reduce(self, space):
-        """
-        XXX to do: remove this __reduce__ method and do
-        a registration with copy_reg, instead.
-        """
         from pypy.interpreter.mixedmodule import MixedModule
         w_mod = space.getbuiltinmodule('_pickle_support')
         mod = space.interp_w(MixedModule, w_mod)
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -419,6 +419,10 @@
             base = object
             baselist = list(cls.__bases__)
 
+            if cls.__dict__.get('_mixin_', False):
+                raise AnnotatorError("cannot use directly the class %r because 
"
+                                     "it is a _mixin_" % (cls,))
+
             # special case: skip BaseException in Python 2.5, and pretend
             # that all exceptions ultimately inherit from Exception instead
             # of BaseException (XXX hack)
diff --git a/rpython/annotator/test/test_annrpython.py 
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -2536,6 +2536,22 @@
         s = a.build_types(f, [])
         assert s.const == 2
 
+    def test_cannot_use_directly_mixin(self):
+        class A(object):
+            _mixin_ = True
+        #
+        def f():
+            return A()
+        a = self.RPythonAnnotator()
+        py.test.raises(annmodel.AnnotatorError, a.build_types, f, [])
+        #
+        class B(object):
+            pass
+        x = B()
+        def g():
+            return isinstance(x, A)
+        py.test.raises(annmodel.AnnotatorError, a.build_types, g, [])
+
     def test_import_from_mixin(self):
         class M(object):
             def f(self):
diff --git a/rpython/flowspace/test/test_model.py 
b/rpython/flowspace/test/test_model.py
--- a/rpython/flowspace/test/test_model.py
+++ b/rpython/flowspace/test/test_model.py
@@ -13,7 +13,7 @@
 class pieces:
     """ The manually-built graph corresponding to the sample_function().
     """
-    i = Variable("i")
+    i0 = Variable("i0")
     i1 = Variable("i1")
     i2 = Variable("i2")
     i3 = Variable("i3")
@@ -25,12 +25,12 @@
     conditionop = SpaceOperation("gt", [i1, Constant(0)], conditionres)
     addop = SpaceOperation("add", [sum2, i2], sum3)
     decop = SpaceOperation("sub", [i2, Constant(1)], i3)
-    startblock = Block([i])
+    startblock = Block([i0])
     headerblock = Block([i1, sum1])
     whileblock = Block([i2, sum2])
 
     graph = FunctionGraph("f", startblock)
-    startblock.closeblock(Link([i, Constant(0)], headerblock))
+    startblock.closeblock(Link([i0, Constant(0)], headerblock))
     headerblock.operations.append(conditionop)
     headerblock.exitswitch = conditionres
     headerblock.closeblock(Link([sum1], graph.returnblock, False),
@@ -55,7 +55,7 @@
 def test_graphattributes():
     assert graph.startblock is pieces.startblock
     assert graph.returnblock is pieces.headerblock.exits[0].target
-    assert graph.getargs() == [pieces.i]
+    assert graph.getargs() == [pieces.i0]
     assert [graph.getreturnvar()] == graph.returnblock.inputargs
     assert graph.source == inspect.getsource(sample_function)
 
diff --git a/rpython/jit/backend/llsupport/test/ztranslation_test.py 
b/rpython/jit/backend/llsupport/test/ztranslation_test.py
--- a/rpython/jit/backend/llsupport/test/ztranslation_test.py
+++ b/rpython/jit/backend/llsupport/test/ztranslation_test.py
@@ -21,7 +21,7 @@
         # this is a basic test that tries to hit a number of features and their
         # translation:
         # - jitting of loops and bridges
-        # - virtualizables
+        # - two virtualizable types
         # - set_param interface
         # - profiler
         # - full optimizer
@@ -79,22 +79,28 @@
                 if rposix.get_errno() != total: raise ValueError
             return chr(total % 253)
         #
+        class Virt2(object):
+            _virtualizable_ = ['i']
+            def __init__(self, i):
+                self.i = i
         from rpython.rlib.libffi import types, CDLL, ArgChain
         from rpython.rlib.test.test_clibffi import get_libm_name
         libm_name = get_libm_name(sys.platform)
-        jitdriver2 = JitDriver(greens=[], reds = ['i', 'func', 'res', 'x'])
+        jitdriver2 = JitDriver(greens=[], reds = ['v2', 'func', 'res', 'x'],
+                               virtualizables = ['v2'])
         def libffi_stuff(i, j):
             lib = CDLL(libm_name)
             func = lib.getpointer('fabs', [types.double], types.double)
             res = 0.0
             x = float(j)
-            while i > 0:
-                jitdriver2.jit_merge_point(i=i, res=res, func=func, x=x)
+            v2 = Virt2(i)
+            while v2.i > 0:
+                jitdriver2.jit_merge_point(v2=v2, res=res, func=func, x=x)
                 promote(func)
                 argchain = ArgChain()
                 argchain.arg(x)
                 res = func.call(argchain, rffi.DOUBLE)
-                i -= 1
+                v2.i -= 1
             return res
         #
         def main(i, j):
diff --git a/rpython/jit/backend/x86/callbuilder.py 
b/rpython/jit/backend/x86/callbuilder.py
--- a/rpython/jit/backend/x86/callbuilder.py
+++ b/rpython/jit/backend/x86/callbuilder.py
@@ -129,7 +129,7 @@
         self.mc.MOV(heap(fastgil), css_value)
         #
         if not we_are_translated():        # for testing: we should not access
-            self.mc.ADD(ebp, imm(1))       # ebp any more; and ignore 'fastgil'
+            self.mc.ADD(ebp, imm(1))       # ebp any more
 
     def move_real_result_and_call_reacqgil_addr(self, fastgil):
         from rpython.jit.backend.x86 import rx86
diff --git a/rpython/jit/metainterp/test/test_virtualizable.py 
b/rpython/jit/metainterp/test/test_virtualizable.py
--- a/rpython/jit/metainterp/test/test_virtualizable.py
+++ b/rpython/jit/metainterp/test/test_virtualizable.py
@@ -1611,6 +1611,40 @@
                  op.getopnum() == rop.GUARD_NOT_FORCED_2]
             assert len(l) == 0
 
+    def test_two_virtualizable_types(self):
+        class A:
+            _virtualizable_ = ['x']
+            def __init__(self, x):
+                self.x = x
+
+        class B:
+            _virtualizable_ = ['lst[*]']
+            def __init__(self, lst):
+                self.lst = lst
+
+        driver_a = JitDriver(greens=[], reds=['a'], virtualizables=['a'])
+        driver_b = JitDriver(greens=[], reds=['b'], virtualizables=['b'])
+
+        def foo_a(a):
+            while a.x > 0:
+                driver_a.jit_merge_point(a=a)
+                a.x -= 2
+            return a.x
+
+        def foo_b(b):
+            while b.lst[0] > 0:
+                driver_b.jit_merge_point(b=b)
+                b.lst[0] -= 2
+            return b.lst[0]
+
+        def f():
+            return foo_a(A(13)) * 100 + foo_b(B([13]))
+
+        assert f() == -101
+        res = self.meta_interp(f, [], listops=True)
+        assert res == -101
+
+
 class TestLLtype(ExplicitVirtualizableTests,
                  ImplicitVirtualizableTests,
                  LLJitMixin):
diff --git a/rpython/rlib/rStringIO.py b/rpython/rlib/rStringIO.py
--- a/rpython/rlib/rStringIO.py
+++ b/rpython/rlib/rStringIO.py
@@ -8,8 +8,6 @@
     The fastest path through this code is for the case of a bunch of write()
     followed by getvalue().
     """
-    _mixin_ = True        # for interp_stringio.py
-
     def __init__(self):
         self.init()
 
diff --git a/rpython/rlib/rmd5.py b/rpython/rlib/rmd5.py
--- a/rpython/rlib/rmd5.py
+++ b/rpython/rlib/rmd5.py
@@ -132,8 +132,6 @@
 class RMD5(object):
     """RPython-level MD5 object.
     """
-    _mixin_ = True        # for interp_md5.py
-
     def __init__(self, initialdata=''):
         self._init()
         self.update(initialdata)
diff --git a/rpython/rlib/rsha.py b/rpython/rlib/rsha.py
--- a/rpython/rlib/rsha.py
+++ b/rpython/rlib/rsha.py
@@ -95,8 +95,6 @@
 class RSHA(object):
     """RPython-level SHA object.
     """
-    _mixin_ = True        # for interp_sha.py
-
     def __init__(self, initialdata=''):
         self._init()
         self.update(initialdata)
diff --git a/rpython/rtyper/lltypesystem/lltype.py 
b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -1154,7 +1154,12 @@
                 type(other).__name__,))
         if self._TYPE != other._TYPE:
             raise TypeError("comparing %r and %r" % (self._TYPE, other._TYPE))
-        return self._obj == other._obj
+        try:
+            return self._obj == other._obj
+        except DelayedPointer:
+            # if one of the two pointers is delayed, they cannot
+            # possibly be equal unless they are the same _ptr instance
+            return self is other
 
     def __ne__(self, other):
         return not (self == other)
diff --git a/rpython/rtyper/normalizecalls.py b/rpython/rtyper/normalizecalls.py
--- a/rpython/rtyper/normalizecalls.py
+++ b/rpython/rtyper/normalizecalls.py
@@ -93,7 +93,12 @@
         return False   # nothing to do, all signatures already match
 
     shape_cnt, shape_keys, shape_star = shape
-    assert not shape_star, "XXX not implemented"
+    if shape_star:
+        raise TyperError(
+            "not implemented: a call is done with a '*' argument, and the"
+            " multiple functions or methods that it can go to don't have"
+            " all the same signature (different argument names or defaults)."
+            " The call can go to:\n%s" % '\n'.join(map(repr, graphs)))
 
     # for the first 'shape_cnt' arguments we need to generalize to
     # a common type
diff --git a/rpython/rtyper/test/test_annlowlevel.py 
b/rpython/rtyper/test/test_annlowlevel.py
--- a/rpython/rtyper/test/test_annlowlevel.py
+++ b/rpython/rtyper/test/test_annlowlevel.py
@@ -64,3 +64,13 @@
         assert lltype.typeOf(ptr) == OBJECTPTR
         y = annlowlevel.cast_base_ptr_to_instance(X, ptr)
         assert y is x
+
+    def test_delayedptr(self):
+        FUNCTYPE = lltype.FuncType([], lltype.Signed)
+        name = "delayed!myfunc"
+        delayedptr1 = lltype._ptr(lltype.Ptr(FUNCTYPE), name, solid=True)
+        delayedptr2 = lltype._ptr(lltype.Ptr(FUNCTYPE), name, solid=True)
+        assert delayedptr1 == delayedptr1
+        assert delayedptr1 != delayedptr2
+        assert bool(delayedptr1)
+        assert delayedptr1 != lltype.nullptr(FUNCTYPE)
diff --git a/rpython/rtyper/test/test_llinterp.py 
b/rpython/rtyper/test/test_llinterp.py
--- a/rpython/rtyper/test/test_llinterp.py
+++ b/rpython/rtyper/test/test_llinterp.py
@@ -129,7 +129,7 @@
     info = py.test.raises(LLException, "interp.eval_graph(graph, values)")
     try:
         got = interp.find_exception(info.value)
-    except ValueError, message:
+    except ValueError as message:
         got = 'None %r' % message
     assert got is exc, "wrong exception type, expected %r got %r" % (exc, got)
 
diff --git a/rpython/rtyper/test/test_normalizecalls.py 
b/rpython/rtyper/test/test_normalizecalls.py
--- a/rpython/rtyper/test/test_normalizecalls.py
+++ b/rpython/rtyper/test/test_normalizecalls.py
@@ -192,6 +192,25 @@
         import re
         assert re.match(msg, excinfo.value.args[0])
 
+    def test_methods_with_named_arg_call(self):
+        class Base:
+            def fn(self, y):
+                raise NotImplementedError
+        class Sub1(Base):
+            def fn(self, y):
+                return 1 + y
+        class Sub2(Base):
+            def fn(self, x):    # different name!
+                return x - 2
+        def dummyfn(n):
+            if n == 1:
+                s = Sub1()
+            else:
+                s = Sub2()
+            return s.fn(*(n,))
+
+        py.test.raises(TyperError, self.rtype, dummyfn, [int], int)
+
 
 class PBase:
     def fn(self):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to