str.encode() and str.decode() no longer check the encoding and errors
in development mode or in debug mode during Python finalization. The
codecs machinery can no longer work on very late calls to
str.encode() and str.decode().
This change should help to call _PyObject_Dump() to debug during late
Python finalization.
--- /dev/null
+str.encode() and str.decode() no longer check the encoding and errors in
+development mode or in debug mode during Python finalization. The codecs
+machinery can no longer work on very late calls to str.encode() and
+str.decode().
return 0;
}
+ /* Disable checks during Python finalization. For example, it allows to
+ call _PyObject_Dump() during finalization for debugging purpose. */
+ if (interp->finalizing) {
+ return 0;
+ }
+
if (encoding != NULL) {
PyObject *handler = _PyCodec_Lookup(encoding);
if (handler == NULL) {