summaryrefslogtreecommitdiffstats
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-04-02 21:18:34 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-04-02 21:18:34 (GMT)
commit789be0c0a0656d17f831aa781cf7c5d55e5b4835 (patch)
tree8ce796bd726fcbbb4c9f19ae2d3601517ebbee91 /Objects/typeobject.c
parent48e3fd240fc6338fbcbbc9c1c8a7d118faca924a (diff)
downloadcpython-789be0c0a0656d17f831aa781cf7c5d55e5b4835.zip
cpython-789be0c0a0656d17f831aa781cf7c5d55e5b4835.tar.gz
cpython-789be0c0a0656d17f831aa781cf7c5d55e5b4835.tar.bz2
Issue #2396: backport the memoryview object.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 4c397f7..cf5e2a9 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2304,6 +2304,8 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
Py_TPFLAGS_BASETYPE;
if (base->tp_flags & Py_TPFLAGS_HAVE_GC)
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
+ if (base->tp_flags & Py_TPFLAGS_HAVE_NEWBUFFER)
+ type->tp_flags |= Py_TPFLAGS_HAVE_NEWBUFFER;
/* It's a new-style number unless it specifically inherits any
old-style numeric behavior */
@@ -3596,6 +3598,8 @@ add_getset(PyTypeObject *type, PyGetSetDef *gsp)
return 0;
}
+#define BUFFER_FLAGS (Py_TPFLAGS_HAVE_GETCHARBUFFER | Py_TPFLAGS_HAVE_NEWBUFFER)
+
static void
inherit_special(PyTypeObject *type, PyTypeObject *base)
{
@@ -3603,9 +3607,9 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
/* Special flag magic */
if (!type->tp_as_buffer && base->tp_as_buffer) {
- type->tp_flags &= ~Py_TPFLAGS_HAVE_GETCHARBUFFER;
+ type->tp_flags &= ~BUFFER_FLAGS;
type->tp_flags |=
- base->tp_flags & Py_TPFLAGS_HAVE_GETCHARBUFFER;
+ base->tp_flags & BUFFER_FLAGS;
}
if (!type->tp_as_sequence && base->tp_as_sequence) {
type->tp_flags &= ~Py_TPFLAGS_HAVE_SEQUENCE_IN;