[pypy-commit] pypy py3k: merge default
pjenvey
noreply at buildbot.pypy.org
Sat Aug 2 00:23:22 CEST 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r72637:33d48832dcfd
Date: 2014-08-01 15:21 -0700
http://bitbucket.org/pypy/pypy/changeset/33d48832dcfd/
Log: merge default
diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst
--- a/pypy/doc/coding-guide.rst
+++ b/pypy/doc/coding-guide.rst
@@ -740,7 +740,7 @@
Adding an entry under pypy/module (e.g. mymodule) entails automatic
creation of a new config option (such as --withmod-mymodule and
---withoutmod-mymodule (the later being the default)) for py.py and
+--withoutmod-mymodule (the latter being the default)) for py.py and
translate.py.
Testing modules in ``lib_pypy/``
@@ -931,7 +931,7 @@
assert self.result == 2 ** 6
which executes the code string function with the given arguments at app level.
-Note the use of ``w_result`` in ``setup_class`` but self.result in the test
+Note the use of ``w_result`` in ``setup_class`` but self.result in the test.
Here is how to define an app level class in ``setup_class`` that can be used
in subsequent tests::
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -328,7 +328,7 @@
* directly calling the internal magic methods of a few built-in types
with invalid arguments may have a slightly different result. For
example, ``[].__add__(None)`` and ``(2).__add__(None)`` both return
- ``NotImplemented`` on PyPy; on CPython, only the later does, and the
+ ``NotImplemented`` on PyPy; on CPython, only the latter does, and the
former raises ``TypeError``. (Of course, ``[]+None`` and ``2+None``
both raise ``TypeError`` everywhere.) This difference is an
implementation detail that shows up because of internal C-level slots
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/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
@@ -394,6 +394,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/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/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/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_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):
More information about the pypy-commit
mailing list