From 3fd77ba4e4b8075d8188b2a2a89a804de11078d1 Mon Sep 17 00:00:00 2001 From: Hanno Schlichting Date: Wed, 18 Jan 2017 19:45:26 +0100 Subject: [PATCH] Update ExtensionClass.h, require ExtensionClass >= 4.2. --- buildout.cfg | 1 + include/ExtensionClass/ExtensionClass.h | 70 ++++++++++++------------- setup.py | 2 +- 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/buildout.cfg b/buildout.cfg index d12c820..7f20af2 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -5,6 +5,7 @@ parts = interpreter test [versions] Persistence = +ExtensionClass = [interpreter] recipe = zc.recipe.egg diff --git a/include/ExtensionClass/ExtensionClass.h b/include/ExtensionClass/ExtensionClass.h index 5be7f99..227c525 100644 --- a/include/ExtensionClass/ExtensionClass.h +++ b/include/ExtensionClass/ExtensionClass.h @@ -26,54 +26,54 @@ - The include file, 'ExtensionClass.h', must be included. - The type structure is declared to be of type - 'PyExtensionClass', rather than of type 'PyTypeObject'. + 'PyExtensionClass', rather than of type 'PyTypeObject'. - The type structure has an additional member that must be defined - after the documentation string. This extra member is a method chain - ('PyMethodChain') containing a linked list of method definition - ('PyMethodDef') lists. Method chains can be used to implement - method inheritance in C. Most extensions don't use method chains, - but simply define method lists, which are null-terminated arrays - of method definitions. A macro, 'METHOD_CHAIN' is defined in - 'ExtensionClass.h' that converts a method list to a method chain. - (See the example below.) + after the documentation string. This extra member is a method chain + ('PyMethodChain') containing a linked list of method definition + ('PyMethodDef') lists. Method chains can be used to implement + method inheritance in C. Most extensions don't use method chains, + but simply define method lists, which are null-terminated arrays + of method definitions. A macro, 'METHOD_CHAIN' is defined in + 'ExtensionClass.h' that converts a method list to a method chain. + (See the example below.) - Module functions that create new instances must be replaced by an - '__init__' method that initializes, but does not create storage for - instances. + '__init__' method that initializes, but does not create storage for + instances. - The extension class must be initialized and exported to the module - with:: + with:: - PyExtensionClass_Export(d,"name",type); + PyExtensionClass_Export(d,"name",type); - where 'name' is the module name and 'type' is the extension class - type object. + where 'name' is the module name and 'type' is the extension class + type object. Attribute lookup - Attribute lookup is performed by calling the base extension class - 'getattr' operation for the base extension class that includes C - data, or for the first base extension class, if none of the base - extension classes include C data. 'ExtensionClass.h' defines a - macro 'Py_FindAttrString' that can be used to find an object's - attributes that are stored in the object's instance dictionary or - in the object's class or base classes:: + Attribute lookup is performed by calling the base extension class + 'getattr' operation for the base extension class that includes C + data, or for the first base extension class, if none of the base + extension classes include C data. 'ExtensionClass.h' defines a + macro 'Py_FindAttrString' that can be used to find an object's + attributes that are stored in the object's instance dictionary or + in the object's class or base classes:: - v = Py_FindAttrString(self,name); + v = Py_FindAttrString(self,name); - In addition, a macro is provided that replaces 'Py_FindMethod' - calls with logic to perform the same sort of lookup that is - provided by 'Py_FindAttrString'. + In addition, a macro is provided that replaces 'Py_FindMethod' + calls with logic to perform the same sort of lookup that is + provided by 'Py_FindAttrString'. Linking - The extension class mechanism was designed to be useful with - dynamically linked extension modules. Modules that implement - extension classes do not have to be linked against an extension - class library. The macro 'PyExtensionClass_Export' imports the - 'ExtensionClass' module and uses objects imported from this module - to initialize an extension class with necessary behavior. + The extension class mechanism was designed to be useful with + dynamically linked extension modules. Modules that implement + extension classes do not have to be linked against an extension + class library. The macro 'PyExtensionClass_Export' imports the + 'ExtensionClass' module and uses objects imported from this module + to initialize an extension class with necessary behavior. */ @@ -186,7 +186,7 @@ static struct ExtensionClassCAPIstruct { /* The following macro can be used to define an extension base class that only provides method and that is used as a pure mix-in class. */ #define PURE_MIXIN_CLASS(NAME,DOC,METHODS) \ -static PyExtensionClass NAME ## Type = { PyObject_HEAD_INIT(NULL) 0, # NAME, \ +static PyExtensionClass NAME ## Type = { PyVarObject_HEAD_INIT(NULL, 0) # NAME, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0 , DOC, (traverseproc)METHODS, } @@ -239,12 +239,12 @@ static PyExtensionClass NAME ## Type = { PyObject_HEAD_INIT(NULL) 0, # NAME, \ #define PyExtensionClass_Export(D,N,T) \ if (! ExtensionClassImported || \ - PyExtensionClassCAPI->PyExtensionClass_Export_((D),(N),&(T)) < 0) return; + PyExtensionClassCAPI->PyExtensionClass_Export_((D),(N),&(T)) < 0) return NULL; #define ExtensionClassImported \ ((PyExtensionClassCAPI != NULL) || \ - (PyExtensionClassCAPI = PyCObject_Import("ExtensionClass","CAPI2"))) + (PyExtensionClassCAPI = PyCapsule_Import("ExtensionClass.CAPI2", 0))) /* These are being overridded to use tp_free when used with diff --git a/setup.py b/setup.py index f97e760..9af1f13 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,7 @@ ], ext_modules=ext_modules, install_requires=[ - 'ExtensionClass >= 4.1.2', + 'ExtensionClass >= 4.2.0', 'persistent >= 4.1.1', 'six', ],