File tree 2 files changed +15
-7
lines changed 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 70
70
python : pypy3
71
71
arch : x64
72
72
73
- # TODO: renable
74
- # Currently segfaults on macOS Python 3.9
75
- - runs-on : macos-latest
76
- python : 3.9
77
- arch : x64
78
-
79
73
name : " 🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • ${{ matrix.arch }} ${{ matrix.args }}"
80
74
runs-on : ${{ matrix.runs-on }}
81
75
Original file line number Diff line number Diff line change @@ -452,6 +452,12 @@ class cpp_function : public function {
452
452
453
453
// / When a cpp_function is GCed, release any memory allocated by pybind11
454
454
static void destruct (detail::function_record *rec) {
455
+ // If on Python 3.9, check the interpreter "MICRO" (patch) version.
456
+ // If this is running on 3.9.0, we have to work around a bug.
457
+ #if !defined(PYPY_VERSION) && PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 9
458
+ static bool is_zero = Py_GetVersion ()[4 ] == ' 0' ;
459
+ #endif
460
+
455
461
while (rec) {
456
462
detail::function_record *next = rec->next ;
457
463
if (rec->free_data )
@@ -466,7 +472,15 @@ class cpp_function : public function {
466
472
}
467
473
if (rec->def ) {
468
474
std::free (const_cast <char *>(rec->def ->ml_doc ));
469
- delete rec->def ;
475
+ // Python 3.9.0 decref's these in the wrong order; rec->def
476
+ // If loaded on 3.9.0, let these leak (use Python 3.9.1 at runtime to fix)
477
+ // See https://github.com/python/cpython/pull/22670
478
+ #if !defined(PYPY_VERSION) && PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 9
479
+ if (!is_zero)
480
+ delete rec->def ;
481
+ #else
482
+ delete rec->def ;
483
+ #endif
470
484
}
471
485
delete rec;
472
486
rec = next;
You can’t perform that action at this time.
0 commit comments