[pypy-commit] pypy missing-tp_new: Found out that the problem is not specific to __new__, but shows up for any slot.
arigo
pypy.commits at gmail.com
Sun Oct 30 11:26:18 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: missing-tp_new
Changeset: r87993:555dee70591b
Date: 2016-10-30 16:25 +0100
http://bitbucket.org/pypy/pypy/changeset/555dee70591b/
Log: Found out that the problem is not specific to __new__, but shows up
for any slot.
diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -430,6 +430,22 @@
ref = make_ref(space, w_obj)
api.Py_DecRef(ref)
+ def test_nb_add_from_python(self, space, api):
+ w_date = space.appexec([], """():
+ class DateType(object):
+ def __add__(self, other):
+ return 'sum!'
+ return DateType()
+ """)
+ w_datetype = space.type(w_date)
+ py_date = make_ref(space, w_date)
+ py_datetype = rffi.cast(PyTypeObjectPtr, make_ref(space, w_datetype))
+ assert py_datetype.c_tp_as_number
+ assert py_datetype.c_tp_as_number.c_nb_add
+ w_obj = generic_cpy_call(space, py_datetype.c_tp_as_number.c_nb_add,
+ py_date, py_date)
+ assert space.str_w(w_obj) == 'sum!'
+
def test_tp_new_from_python(self, space, api):
w_date = space.appexec([], """():
class Date(object):
More information about the pypy-commit
mailing list