From eea4718e814b8ec054557aa87d6c122305bf6f0b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 11 Feb 2003 20:39:59 +0000 Subject: [PATCH] Fix from SF #681367: inherit tp_as_buffer. This only applies to C types -- Python types already inherited this. --- Misc/NEWS | 4 ++++ Objects/typeobject.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 59ad277824c..ed4f7cf9ac0 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -258,6 +258,10 @@ Build C API ----- +- A C type that inherits from a base type that defines tp_as_buffer + will now inherit the tp_as_buffer pointer if it doesn't define one. + (SF #681367) + - The PyArg_Parse functions now issue a DeprecationWarning if a float argument is provided when an integer is specified (this affects the 'b', 'B', 'h', 'H', 'i', and 'l' codes). Future versions of Python will diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 38d5956d134..baea55a7294 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2915,6 +2915,8 @@ PyType_Ready(PyTypeObject *type) type->tp_as_sequence = base->tp_as_sequence; if (type->tp_as_mapping == NULL) type->tp_as_mapping = base->tp_as_mapping; + if (type->tp_as_buffer == NULL) + type->tp_as_buffer = base->tp_as_buffer; } /* Link into each base class's list of subclasses */