STINNER Victor <vstin...@python.org> added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46476>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to