[pypy-commit] pypy py3k: Kill Py_TPFLAGS_CHECKTYPES: it doesn't exist on CPython3
rlamy
pypy.commits at gmail.com
Mon Oct 3 15:43:58 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k
Changeset: r87559:87803e83eb25
Date: 2016-10-03 20:43 +0100
http://bitbucket.org/pypy/pypy/changeset/87803e83eb25/
Log: Kill Py_TPFLAGS_CHECKTYPES: it doesn't exist on CPython3
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -121,7 +121,7 @@
METH_COEXIST METH_STATIC METH_CLASS Py_TPFLAGS_BASETYPE Py_MAX_FMT
METH_NOARGS METH_VARARGS METH_KEYWORDS METH_O Py_TPFLAGS_HAVE_INPLACEOPS
Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_HAVE_NEWBUFFER
-Py_LT Py_LE Py_EQ Py_NE Py_GT Py_GE Py_TPFLAGS_CHECKTYPES Py_MAX_NDIMS
+Py_LT Py_LE Py_EQ Py_NE Py_GT Py_GE Py_MAX_NDIMS
Py_CLEANUP_SUPPORTED
""".split()
for name in constant_names:
diff --git a/pypy/module/cpyext/include/object.h b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -197,13 +197,9 @@
typedef int (*traverseproc)(PyObject *, visitproc, void *);
typedef struct {
- /* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all
- arguments are guaranteed to be of the object's type (modulo
- coercion hacks -- i.e. if the type's coercion function
- returns other types, then these are allowed as well). Numbers that
- have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both*
- arguments for proper type and implement the necessary conversions
- in the slot functions themselves. */
+ /* Number implementations must check *both*
+ arguments for proper type and implement the necessary conversions
+ in the slot functions themselves. */
binaryfunc nb_add;
binaryfunc nb_subtract;
@@ -414,9 +410,6 @@
/* PySequenceMethods and PyNumberMethods contain in-place operators */
#define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3)
-/* PyNumberMethods do their own coercion */
-#define Py_TPFLAGS_CHECKTYPES (1L<<4)
-
/* tp_richcompare is defined */
#define Py_TPFLAGS_HAVE_RICHCOMPARE (1L<<5)
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,7 +4,7 @@
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.cpyext.api import (
- cpython_api, generic_cpy_call, PyObject, Py_ssize_t, Py_TPFLAGS_CHECKTYPES,
+ cpython_api, generic_cpy_call, PyObject, Py_ssize_t,
Py_buffer, mangle_name, pypy_decl)
from pypy.module.cpyext.typeobjectdefs import (
unaryfunc, wrapperfunc, ternaryfunc, PyTypeObjectPtr, binaryfunc, ternaryfunc,
@@ -81,9 +81,6 @@
check_num_args(space, w_args, 1)
args_w = space.fixedview(w_args)
ref = make_ref(space, w_self)
- if (not ref.c_ob_type.c_tp_flags & Py_TPFLAGS_CHECKTYPES and
- not space.issubtype_w(space.type(args_w[0]), space.type(w_self))):
- return space.w_NotImplemented
Py_DecRef(space, ref)
return generic_cpy_call(space, func_binary, w_self, args_w[0])
@@ -92,9 +89,6 @@
check_num_args(space, w_args, 1)
args_w = space.fixedview(w_args)
ref = make_ref(space, w_self)
- if (not ref.c_ob_type.c_tp_flags & Py_TPFLAGS_CHECKTYPES and
- not space.issubtype_w(space.type(args_w[0]), space.type(w_self))):
- return space.w_NotImplemented
Py_DecRef(space, ref)
return generic_cpy_call(space, func_binary, args_w[0], w_self)
@@ -114,9 +108,6 @@
check_num_argsv(space, w_args, 1, 2)
args_w = space.fixedview(w_args)
ref = make_ref(space, w_self)
- if (not ref.c_ob_type.c_tp_flags & Py_TPFLAGS_CHECKTYPES and
- not space.issubtype_w(space.type(args_w[0]), space.type(w_self))):
- return space.w_NotImplemented
Py_DecRef(space, ref)
arg3 = space.w_None
if len(args_w) > 1:
@@ -321,7 +312,7 @@
self.strides = [1]
else:
self.strides = strides
- self.ndim = ndim
+ self.ndim = ndim
self.itemsize = itemsize
self.readonly = readonly
@@ -597,12 +588,12 @@
buff_fn = w_type.getdictvalue(space, '__buffer__')
if buff_fn is None:
return
- @cpython_api([PyObject, Py_bufferP, rffi.INT_real],
+ @cpython_api([PyObject, Py_bufferP, rffi.INT_real],
rffi.INT_real, header=None, error=-1)
@func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name))
def buff_w(space, w_self, pybuf, flags):
# XXX this is wrong, needs a test
- raise oefmt(space.w_NotImplemented,
+ raise oefmt(space.w_NotImplemented,
"calling bf_getbuffer on a builtin type not supported yet")
#args = Arguments(space, [w_self],
# w_stararg=w_args, w_starstararg=w_kwds)
diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c
--- a/pypy/module/cpyext/test/foo.c
+++ b/pypy/module/cpyext/test/foo.c
@@ -281,7 +281,7 @@
0, /*tp_setattro*/
0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
@@ -340,7 +340,7 @@
0, /*tp_setattro*/
0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
@@ -408,7 +408,7 @@
0, /*tp_setattro*/
0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
@@ -488,7 +488,7 @@
0, /*tp_setattro*/
0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
@@ -572,7 +572,7 @@
0, /*tp_setattro*/
0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
diff --git a/pypy/module/cpyext/test/foo3.c b/pypy/module/cpyext/test/foo3.c
--- a/pypy/module/cpyext/test/foo3.c
+++ b/pypy/module/cpyext/test/foo3.c
@@ -8,7 +8,7 @@
return newType;
}
-#define BASEFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES
+#define BASEFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
PyTypeObject footype = {
PyVarObject_HEAD_INIT(NULL, 0)
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
@@ -848,7 +848,7 @@
return NULL;
IntLike_Type.tp_as_number = &intlike_as_number;
- IntLike_Type.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES;
+ IntLike_Type.tp_flags |= Py_TPFLAGS_DEFAULT;
intlike_as_number.nb_add = intlike_nb_add;
intlike_as_number.nb_power = intlike_nb_pow;
if (PyType_Ready(&IntLike_Type) < 0) return NULL;
@@ -868,7 +868,7 @@
if (!PyArg_ParseTuple(args, "l", &intval))
return NULL;
- IntLike_Type_NoOp.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES;
+ IntLike_Type_NoOp.tp_flags |= Py_TPFLAGS_DEFAULT;
if (PyType_Ready(&IntLike_Type_NoOp) < 0) return NULL;
intObjNoOp = PyObject_New(IntLikeObjectNoOp, &IntLike_Type_NoOp);
if (!intObjNoOp) {
@@ -986,8 +986,7 @@
PyObject *o;
Foo_Type.tp_basicsize = sizeof(FooObject);
Foo_Type.tp_dealloc = &dealloc_foo;
- Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES
- | Py_TPFLAGS_BASETYPE;
+ Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
Foo_Type.tp_new = &new_foo;
Foo_Type.tp_free = &PyObject_Del;
if (PyType_Ready(&Foo_Type) < 0) return NULL;
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
@@ -18,8 +18,7 @@
Py_TPFLAGS_HEAPTYPE, METH_VARARGS, METH_KEYWORDS, CANNOT_FAIL,
Py_TPFLAGS_HAVE_GETCHARBUFFER, build_type_checkers, StaticObjectBuilder,
PyObjectFields, Py_TPFLAGS_BASETYPE, PyTypeObject, PyTypeObjectPtr,
- Py_TPFLAGS_HAVE_NEWBUFFER, Py_TPFLAGS_CHECKTYPES,
- Py_TPFLAGS_HAVE_INPLACEOPS)
+ Py_TPFLAGS_HAVE_NEWBUFFER, Py_TPFLAGS_HAVE_INPLACEOPS)
from pypy.module.cpyext.methodobject import (W_PyCClassMethodObject,
W_PyCWrapperObject, PyCFunction_NewEx, PyCFunction_typedef, PyMethodDef,
W_PyCMethodObject, W_PyCFunctionObject)
@@ -389,7 +388,6 @@
pto.c_tp_basicsize = base_pto.c_tp_basicsize
if pto.c_tp_itemsize < base_pto.c_tp_itemsize:
pto.c_tp_itemsize = base_pto.c_tp_itemsize
- pto.c_tp_flags |= base_pto.c_tp_flags & Py_TPFLAGS_CHECKTYPES
pto.c_tp_flags |= base_pto.c_tp_flags & Py_TPFLAGS_HAVE_INPLACEOPS
flags = rffi.cast(lltype.Signed, pto.c_tp_flags)
base_object_pyo = make_ref(space, space.w_object)
@@ -726,9 +724,8 @@
# inheriting tp_as_* slots
base = py_type.c_tp_base
if base:
- if not py_type.c_tp_as_number:
+ if not py_type.c_tp_as_number:
py_type.c_tp_as_number = base.c_tp_as_number
- py_type.c_tp_flags |= base.c_tp_flags & Py_TPFLAGS_CHECKTYPES
py_type.c_tp_flags |= base.c_tp_flags & Py_TPFLAGS_HAVE_INPLACEOPS
if not py_type.c_tp_as_sequence:
py_type.c_tp_as_sequence = base.c_tp_as_sequence
More information about the pypy-commit
mailing list