| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 61e40f6 commit d10f154
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -369,6 +369,15 @@ class cpp_function : public function { | |||
| 369 | 369 | } | |
| 370 | 370 | ||
| 371 | 371 | m_ptr = PyCFunction_NewEx(rec->def, rec_capsule.ptr(), scope_module.ptr()); | |
| 372 | + | ||
| 373 | + #if PY_VERSION_HEX >= 0x03090000 | ||
| 374 | + weakref(m_ptr, cpp_function([rec_capsule](handle wr) { | ||
| 375 | + rec_capsule.dec_ref(); | ||
| 376 | + wr.dec_ref(); | ||
| 377 | + })).release(); | ||
| 378 | + rec_capsule.inc_ref(); | ||
| 379 | + #endif | ||
| 380 | + | ||
| 372 | 381 | if (!m_ptr) | |
| 373 | 382 | pybind11_fail("cpp_function::cpp_function(): Could not allocate function object"); | |
| 374 | 383 | } else { | |
@@ -466,7 +475,7 @@ class cpp_function : public function { | |||
| 466 | 475 | } | |
| 467 | 476 | if (rec->def) { | |
| 468 | 477 | std::free(const_cast<char *>(rec->def->ml_doc)); | |
| 469 | - //delete rec->def; | ||
| 478 | + delete rec->def; | ||
| 470 | 479 | } | |
| 471 | 480 | delete rec; | |
| 472 | 481 | rec = next; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments