[pypy-commit] pypy release-pypy3.5-5.x: Fix: 'tp_descr_get(self, NULL, type)' used to give a real undefined
arigo
pypy.commits at gmail.com
Mon Jun 5 15:58:14 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: release-pypy3.5-5.x
Changeset: r91537:b746b3cc0b2a
Date: 2017-06-05 22:57 +0300
http://bitbucket.org/pypy/pypy/changeset/b746b3cc0b2a/
Log: Fix: 'tp_descr_get(self, NULL, type)' used to give a real undefined
value for the second argument if implemented in Python (grafted from
07257b27db4b6e747d50f24108835f3ed3f62a79)
diff --git a/pypy/module/cpyext/test/test_userslots.py b/pypy/module/cpyext/test/test_userslots.py
--- a/pypy/module/cpyext/test/test_userslots.py
+++ b/pypy/module/cpyext/test/test_userslots.py
@@ -51,7 +51,7 @@
w_descr = space.appexec([], """():
class Descr(object):
def __get__(self, obj, type):
- return 42
+ return 42 + (obj is None)
def __set__(self, obj, value):
obj.append('set')
def __delete__(self, obj):
@@ -73,6 +73,11 @@
space, py_descrtype.c_tp_descr_set,
py_descr, py_obj, None) == 0
assert space.eq_w(w_obj, space.wrap(['set', 'del']))
+ #
+ # unbound __get__(self, NULL, type)
+ w_res = generic_cpy_call(space, py_descrtype.c_tp_descr_get,
+ py_descr, None, space.w_int)
+ assert space.int_w(w_res) == 43
class AppTestUserSlots(AppTestCpythonExtensionBase):
def test_tp_hash_from_python(self):
diff --git a/pypy/module/cpyext/userslot.py b/pypy/module/cpyext/userslot.py
--- a/pypy/module/cpyext/userslot.py
+++ b/pypy/module/cpyext/userslot.py
@@ -111,6 +111,8 @@
@slot_function([PyObject, PyObject, PyObject], PyObject)
def slot_tp_descr_get(space, w_self, w_obj, w_type):
+ if w_obj is None:
+ w_obj = space.w_None
return space.get(w_self, w_obj, w_type)
@slot_function([PyObject, PyObject, PyObject], rffi.INT_real, error=-1)
More information about the pypy-commit
mailing list