1- From 452076a52040a789a4b010a6d8d6abda56d060b4 Mon Sep 17 00:00:00 2001
2- From: Jeroen Demeyer <
[email protected] >
3- Date: Thu, 14 Feb 2019 10:02:41 +0100
4- Subject: [PATCH] @cython.trashcan directive to enable the Python trashcan for
5- deallocations
1+ See https://github.com/cython/cython/pull/2842
62
7- ---
8- Cython/Compiler/ModuleNode.py | 10 +++
9- Cython/Compiler/Options.py | 4 +-
10- Cython/Compiler/PyrexTypes.py | 8 +-
11- Cython/Compiler/Symtab.py | 18 +++-
12- Cython/Utility/ExtensionTypes.c | 43 ++++++++++
13- tests/run/trashcan.pyx | 148 ++++++++++++++++++++++++++++++++
14- 6 files changed, 228 insertions(+), 3 deletions(-)
15- create mode 100644 tests/run/trashcan.pyx
3+ and https://github.com/cython/cython/pull/4475
4+
5+ commit c47c4ef735c4b7f1863b21bbe6f112b06c4aad05
6+ Author: Jeroen Demeyer <
[email protected] >
7+ Date: Thu Feb 14 10:02:41 2019 +0100
8+
9+ @cython.trashcan directive to enable the Python trashcan for deallocations
1610
1711diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
1812index 56845330d..3a3e8a956 100644
@@ -147,7 +141,7 @@ diff --git a/Cython/Utility/ExtensionTypes.c b/Cython/Utility/ExtensionTypes.c
147141index dc187ab49..f359165df 100644
148142--- a/Cython/Utility/ExtensionTypes.c
149143+++ b/Cython/Utility/ExtensionTypes.c
150- @@ -119,6 +119,49 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) {
144+ @@ -119,6 +119,54 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) {
151145 return r;
152146 }
153147
@@ -159,7 +153,12 @@ index dc187ab49..f359165df 100644
159153+
160154+ // This requires CPython version >= 2.7.4
161155+ // (or >= 3.2.4 but we don't support such old Python 3 versions anyway)
162- + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070400
156+ + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03080000
157+ + // https://github.com/python/cpython/pull/11841 merged so Cython reimplementation
158+ + // is no longer necessary
159+ + #define __Pyx_TRASHCAN_BEGIN Py_TRASHCAN_BEGIN
160+ + #define __Pyx_TRASHCAN_END Py_TRASHCAN_END
161+ + #elif CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070400
163162+ #define __Pyx_TRASHCAN_BEGIN_CONDITION(op, cond) \
164163+ do { \
165164+ PyThreadState *_tstate = NULL; \
0 commit comments