Author: Ronan Lamy <ronan.l...@gmail.com> Branch: Changeset: r90901:a09ae92a91a0 Date: 2017-04-01 18:01 +0100 http://bitbucket.org/pypy/pypy/changeset/a09ae92a91a0/
Log: kill _XXX and Ellipsis hacks 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 @@ -4,10 +4,10 @@ from rpython.rtyper.lltypesystem import rffi, lltype from rpython.rlib.rarithmetic import widen -from rpython.rlib import rgc # Force registration of gc.collect +from rpython.rlib import rgc # Force registration of gc.collect from pypy.module.cpyext.api import ( - slot_function, generic_cpy_call, PyObject, Py_ssize_t, Py_TPFLAGS_CHECKTYPES, - pypy_decl, Py_buffer, Py_bufferP, PyTypeObjectPtr, cts) + slot_function, generic_cpy_call, PyObject, Py_ssize_t, + Py_TPFLAGS_CHECKTYPES, Py_buffer, Py_bufferP, PyTypeObjectPtr, cts) from pypy.module.cpyext.typeobjectdefs import ( unaryfunc, ternaryfunc, binaryfunc, getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc, inquiry, @@ -792,6 +792,16 @@ return 0 return buff_w +missing_wrappers = ['wrap_indexargfunc', 'wrap_delslice', 'wrap_coercefunc'] +for name in missing_wrappers: + assert name not in globals() + def missing_wrapper(space, w_self, w_args, func, w_kwds): + print "cpyext: missing slot wrapper " + name + raise NotImplementedError("Slot wrapper " + name) + missing_wrapper.__name__ = name + globals()[name] = missing_wrapper + + PyWrapperFlag_KEYWORDS = 1 class TypeSlot: @@ -809,10 +819,7 @@ if WRAPPER is None: wrapper = None else: - wrapper = globals().get(WRAPPER, Ellipsis) - if wrapper is Ellipsis: - assert WRAPPER.endswith('_XXX'), ( - "no wrapper function called %r in slotdefs.py" % WRAPPER) + wrapper = globals()[WRAPPER] # irregular interface, because of tp_getattr/tp_getattro confusion if NAME == "__getattr__": @@ -826,19 +833,9 @@ function = getattr(userslot, FUNCTION or '!missing', None) assert FLAGS == 0 or FLAGS == PyWrapperFlag_KEYWORDS if FLAGS: - if wrapper is Ellipsis: - @func_renamer(WRAPPER) - def wrapper(space, w_self, w_args, func, w_kwds): - print "cpyext missing wrapper", WRAPPER, "for", NAME - raise NotImplementedError("Wrapper for slot " + NAME) wrapper1 = None wrapper2 = wrapper else: - if wrapper is Ellipsis: - @func_renamer(WRAPPER) - def wrapper(space, w_self, w_args, func): - print "cpyext missing wrapper", WRAPPER, "for", NAME - raise NotImplementedError("Wrapper for slot " + NAME) wrapper1 = wrapper wrapper2 = None return TypeSlot(NAME, SLOT, function, wrapper1, wrapper2, DOC) @@ -885,17 +882,15 @@ # Remove comments and tabs # Done. # XXX NOTE that we already tweaked that string manually! -# Also, a few wrapper functions have a name ending in "_XXX" to mean -# that we know it is not implemented so far. slotdefs_str = r""" static slotdef slotdefs[] = { SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc, "x.__len__() <==> len(x)"), SQSLOT("__add__", sq_concat, slot_sq_concat, wrap_binaryfunc, "x.__add__(y) <==> x+y"), - SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc_XXX, + SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc, "x.__mul__(n) <==> x*n"), - SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc_XXX, + SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc, "x.__rmul__(n) <==> n*x"), SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, "x.__getitem__(y) <==> x[y]"), @@ -912,7 +907,7 @@ "x.__setslice__(i, j, y) <==> x[i:j]=y\n\ \n\ Use of negative indices is not supported."), - SQSLOT("__delslice__", sq_ass_slice, slot_sq_ass_slice, wrap_delslice_XXX, + SQSLOT("__delslice__", sq_ass_slice, slot_sq_ass_slice, wrap_delslice, "x.__delslice__(i, j) <==> del x[i:j]\n\ \n\ Use of negative indices is not supported."), @@ -921,7 +916,7 @@ SQSLOT("__iadd__", sq_inplace_concat, NULL, wrap_binaryfunc, "x.__iadd__(y) <==> x+=y"), SQSLOT("__imul__", sq_inplace_repeat, NULL, - wrap_indexargfunc_XXX, "x.__imul__(y) <==> x*=y"), + wrap_indexargfunc, "x.__imul__(y) <==> x*=y"), MPSLOT("__len__", mp_length, slot_mp_length, wrap_lenfunc, "x.__len__() <==> len(x)"), @@ -980,7 +975,7 @@ RBINSLOT("__rxor__", nb_xor, slot_nb_xor, "^"), BINSLOT("__or__", nb_or, slot_nb_or, "|"), RBINSLOT("__ror__", nb_or, slot_nb_or, "|"), - NBSLOT("__coerce__", nb_coerce, slot_nb_coerce, wrap_coercefunc_XXX, + NBSLOT("__coerce__", nb_coerce, slot_nb_coerce, wrap_coercefunc, "x.__coerce__(y) <==> coerce(x, y)"), UNSLOT("__int__", nb_int, slot_nb_int, wrap_unaryfunc, "int(x)"), _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit