Skip to content

Commit e0735bf

Browse files
committed
Update to PyCXX 6.2.4
1 parent ce1da9b commit e0735bf

13 files changed

+566
-1233
lines changed

CXX/IndirectPythonInterface.cxx

+517-3
Large diffs are not rendered by default.

CXX/Python2/ExtensionModule.hxx

+3-14
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ namespace Py
6666
const std::string m_module_name;
6767
const std::string m_full_module_name;
6868
MethodTable m_method_table;
69-
#if PY3
70-
PyModuleDef m_module_def;
71-
#endif
7269
PyObject *m_module;
7370

7471
private:
@@ -136,19 +133,11 @@ namespace Py
136133
{
137134
MethodDefExt<T> *method_def = (*i).second;
138135

139-
#if PY_VERSION_HEX < 0x02070000
140-
static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );
141-
#else
142-
static PyObject *self = PyCapsule_New( this, NULL, NULL );
143-
#endif
136+
static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );
144137

145138
Tuple args( 2 );
146-
args[0] = Object( self );
147-
#if PY_VERSION_HEX < 0x02070000
148-
args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
149-
#else
150-
args[1] = Object( PyCapsule_New( method_def, NULL, NULL ) );
151-
#endif
139+
args[0] = Object( self, true );
140+
args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );
152141

153142
PyObject *func = PyCFunction_New
154143
(

CXX/Python2/ExtensionOldType.hxx

+8-23
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,8 @@ namespace Py
178178
Tuple self( 2 );
179179

180180
self[0] = Object( this );
181-
#if PY_VERSION_HEX < 0x02070000
182-
self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );
183-
#else
184-
self[1] = Object( PyCapsule_New( method_def, NULL, NULL ), true );
185-
#endif
181+
self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );
182+
186183
PyObject *func = PyCFunction_New( &method_def->ext_meth_def, self.ptr() );
187184

188185
return Object(func, true);
@@ -238,12 +235,8 @@ namespace Py
238235

239236
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
240237
T *self = static_cast<T *>( self_in_cobject );
241-
#if PY_VERSION_HEX < 0x02070000
242-
void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
243-
#else
244-
void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
245-
#endif
246-
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>( capsule );
238+
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
239+
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
247240
Object result;
248241

249242
// Adding try & catch in case of STL debug-mode exceptions.
@@ -278,12 +271,8 @@ namespace Py
278271
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
279272
T *self = static_cast<T *>( self_in_cobject );
280273

281-
#if PY_VERSION_HEX < 0x02070000
282-
void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
283-
#else
284-
void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
285-
#endif
286-
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>( capsule );
274+
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
275+
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
287276
Tuple args( _args );
288277

289278
Object result;
@@ -319,12 +308,8 @@ namespace Py
319308
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
320309
T *self = static_cast<T *>( self_in_cobject );
321310

322-
#if PY_VERSION_HEX < 0x02070000
323-
void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
324-
#else
325-
void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
326-
#endif
327-
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>( capsule );
311+
MethodDefExt<T> *meth_def = reinterpret_cast<MethodDefExt<T> *>(
312+
PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
328313

329314
Tuple args( _args );
330315

CXX/Python2/ExtensionTypeBase.hxx

-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ namespace Py
7070
virtual void reinit( Tuple &args, Dict &kwds );
7171

7272
// object basics
73-
#if defined( PYCXX_PYTHON_2TO3 ) || !defined( PY3 )
7473
virtual int print( FILE *, int );
75-
#endif
7674
virtual Object getattr( const char * );
7775
virtual int setattr( const char *, const Object & );
7876
virtual Object getattro( const String & );

0 commit comments

Comments
 (0)