Author: Matti Picus <[email protected]>
Branch: missing-tp_new
Changeset: r89272:0b1631e69bc6
Date: 2016-12-28 20:58 +0200
http://bitbucket.org/pypy/pypy/changeset/0b1631e69bc6/
Log: builtin->tp_str() resolves differently than applevel->tp_str. Add
tp_hash
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -556,6 +556,19 @@
return space.call_function(slot_fn, w_self)
handled = True
+ for tp_name, attr in [('tp_hash', '__hash__'),
+ ]:
+ if name == tp_name:
+ slot_fn = w_type.getdictvalue(space, attr)
+ if slot_fn is None:
+ return
+ @cpython_api([PyObject], lltype.Signed, header=header, error=-1)
+ @func_renamer("cpyext_%s_%s" % (name.replace('.', '_'),
typedef.name))
+ def slot_func(space, w_obj):
+ return space.int_w(space.call_function(slot_fn, w_self))
+ handled = True
+
+
# binary functions
for tp_name, attr in [('tp_as_number.c_nb_add', '__add__'),
('tp_as_number.c_nb_subtract', '__sub__'),
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -276,12 +276,11 @@
for method_name, slot_name, slot_names, slot_apifunc in
slotdefs_for_tp_slots:
if search_dict_w is not None:
# heap type: only look in this exact class
- #if method_name in search_dict_w and method_name == '__new__':
- # import pdb;pdb.set_trace()
w_descr = search_dict_w.get(method_name, None)
else:
# built-in types: expose as many slots as possible, even
# if it happens to come from some parent class
+ slot_apifunc = None # use get_slot_tp_function lookup mechanism
w_descr = w_type.lookup(method_name)
if w_descr is None:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit