summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-10-12 02:38:24 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-10-12 02:38:24 (GMT)
commitfc57ccb98248b4a8f4ba4debdf3791970b136c4d (patch)
treea0aba8c9a056e54a0faa26a619d653905d773540 /Objects
parent401a76dcab6766d85bfcbb7e3705ee376e97bc06 (diff)
downloadcpython-fc57ccb98248b4a8f4ba4debdf3791970b136c4d.zip
cpython-fc57ccb98248b4a8f4ba4debdf3791970b136c4d.tar.gz
cpython-fc57ccb98248b4a8f4ba4debdf3791970b136c4d.tar.bz2
SF bug [#470040] ParseTuple t# vs subclasses.
inherit_slots(): tp_as_buffer was getting inherited as if it were a method pointer, rather than a pointer to a vector of method pointers. As a result, inheriting from a type that implemented buffer methods was ineffective, leaving all the tp_as_buffer slots NULL in the subclass.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ced80ec..a498f0f 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1657,6 +1657,7 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
#define COPYNUM(SLOT) COPYSLOT(tp_as_number->SLOT)
#define COPYSEQ(SLOT) COPYSLOT(tp_as_sequence->SLOT)
#define COPYMAP(SLOT) COPYSLOT(tp_as_mapping->SLOT)
+#define COPYBUF(SLOT) COPYSLOT(tp_as_buffer->SLOT)
/* This won't inherit indirect slots (from tp_as_number etc.)
if type doesn't provide the space. */
@@ -1732,6 +1733,16 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
COPYMAP(mp_ass_subscript);
}
+ if (type->tp_as_buffer != NULL && base->tp_as_buffer != NULL) {
+ basebase = base->tp_base;
+ if (basebase->tp_as_buffer == NULL)
+ basebase = NULL;
+ COPYBUF(bf_getreadbuffer);
+ COPYBUF(bf_getwritebuffer);
+ COPYBUF(bf_getsegcount);
+ COPYBUF(bf_getcharbuffer);
+ }
+
basebase = base->tp_base;
COPYSLOT(tp_dealloc);
@@ -1749,7 +1760,6 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
/* tp_hash see tp_richcompare */
COPYSLOT(tp_call);
COPYSLOT(tp_str);
- COPYSLOT(tp_as_buffer);
if (type->tp_flags & base->tp_flags & Py_TPFLAGS_HAVE_RICHCOMPARE) {
if (type->tp_compare == NULL &&
type->tp_richcompare == NULL &&