Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit 6788bd2

Browse files
committed
remove hack to look up function by offset, not needed by numpy since v1.17
Does not work properly on win64 numpy/numpy#12524, merged in 2018
1 parent b0dc543 commit 6788bd2

File tree

3 files changed

+4
-27
lines changed

3 files changed

+4
-27
lines changed

pypy/module/_hpy_universal/interp_cpy_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def attach_legacy_slot(space, w_type, slotdef, slotnum):
134134
# XXX: we probably need to handle manually these slots
135135
raise NotImplementedError("slot wrapper for slot %d" % num)
136136
funcptr = slotdef.c_pfunc
137-
w_wrapper = wrapper_class(space, w_type, method_name, doc, funcptr, offset=[])
137+
w_wrapper = wrapper_class(space, w_type, method_name, doc, funcptr)
138138
w_type.setdictvalue(space, method_name, w_wrapper)
139139
break
140140
else:

pypy/module/cpyext/methodobject.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,11 @@ class W_PyCWrapperObject(W_Root):
301301
"""
302302
Abstract class; for concrete subclasses, see slotdefs.py
303303
"""
304-
_immutable_fields_ = ['offset[*]']
305-
306-
def __init__(self, space, w_type, method_name, doc, func, offset):
304+
def __init__(self, space, w_type, method_name, doc, func):
307305
self.space = space
308306
self.method_name = method_name
309307
self.doc = doc
310308
self.func = func
311-
self.offset = offset
312309
assert isinstance(w_type, W_TypeObject)
313310
self.w_objclass = w_type
314311

@@ -318,25 +315,8 @@ def descr_call(self, space, w_self, __args__):
318315
def call(self, space, w_self, __args__):
319316
raise NotImplementedError
320317

321-
@jit.unroll_safe
322318
def get_func_to_call(self):
323-
func_to_call = self.func
324-
if self.offset:
325-
pto = as_pyobj(self.space, self.w_objclass)
326-
# make ptr the equivalent of this, using the offsets
327-
#func_to_call = rffi.cast(rffi.VOIDP, ptr.c_tp_as_number.c_nb_multiply)
328-
if pto:
329-
cptr = rffi.cast(rffi.CCHARP, pto)
330-
for o in self.offset:
331-
ptr = rffi.cast(rffi.VOIDPP, rffi.ptradd(cptr, o))[0]
332-
cptr = rffi.cast(rffi.CCHARP, ptr)
333-
func_to_call = rffi.cast(rffi.VOIDP, cptr)
334-
else:
335-
# Should never happen, assert to get a traceback
336-
assert False, "failed to convert w_type %s to PyObject" % str(
337-
self.w_objclass)
338-
assert func_to_call
339-
return func_to_call
319+
return self.func
340320

341321
def check_args(self, __args__, arity):
342322
length = len(__args__.arguments_w)

pypy/module/cpyext/typeobject.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ def add_operators(space, w_type, dict_w, pto, name):
353353
for method_name, slot_names, wrapper_class, doc in slotdefs_for_wrappers:
354354
if method_name in dict_w:
355355
continue
356-
offset = [rffi.offsetof(lltype.typeOf(pto).TO, slot_names[0])]
357356
if len(slot_names) == 1:
358357
func = getattr(pto, slot_names[0])
359358
if slot_names[0] == 'c_tp_hash':
@@ -370,7 +369,6 @@ def add_operators(space, w_type, dict_w, pto, name):
370369
struct = getattr(pto, slot_names[0])
371370
if not struct:
372371
continue
373-
offset.append(rffi.offsetof(lltype.typeOf(struct).TO, slot_names[1]))
374372
func = getattr(struct, slot_names[1])
375373
func_voidp = rffi.cast(rffi.VOIDP, func)
376374
if not func:
@@ -380,8 +378,7 @@ def add_operators(space, w_type, dict_w, pto, name):
380378

381379
assert issubclass(wrapper_class, W_PyCWrapperObject)
382380

383-
w_obj = wrapper_class(space, w_type, method_name, doc, func_voidp,
384-
offset=offset[:])
381+
w_obj = wrapper_class(space, w_type, method_name, doc, func_voidp)
385382
dict_w[method_name] = w_obj
386383
if pto.c_tp_doc:
387384
raw_doc = rffi.constcharp2str(pto.c_tp_doc)

0 commit comments

Comments
 (0)