Message411372
> See branch https://github.com/kumaraditya303/cpython/commits/fix-code
Oh nice, I like this new _Py_Deepfreeze_Fini() function :-) I suggest to create a function specific to only clear immortal code objects. In my experience, it's important to control exactly when objects are cleared at Python exit: Py_Finalize() is complex and fragile. See my notes:
https://pythondev.readthedocs.io/finalization.html
Be careful, Python must remain usable after Py_Finalize(): it's legit to call Py_Initialize() again and execute new Python code. Example executing the same code 4 times, each time Py_Initialize() and Py_Finalize() are called:
./Programs/_testembed test_repeated_init_exec 'print("Hello")'
My _PyStaticMethod_Dealloc() implementation uses Py_CLEAR() rather than Py_XDECREF() to set structure members to NULL.
Moreover, there are more things than just co_quickened which should be cleared. I suggest to add a new function to clear an "immortal" code object. For example, I also suggest to call PyObject_ClearWeakRefs(). I guess that co_extra should also be cleared. |
|
Date |
User |
Action |
Args |
2022-01-23 14:00:07 | vstinner | set | recipients:
+ vstinner, gvanrossum, Mark.Shannon, eric.snow, corona10, kumaraditya |
2022-01-23 14:00:07 | vstinner | set | messageid: <1642946407.23.0.125152712939.issue46476@roundup.psfhosted.org> |
2022-01-23 14:00:07 | vstinner | link | issue46476 messages |
2022-01-23 14:00:06 | vstinner | create | |
|