summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-07 14:07:42 (GMT)
committerGitHub <noreply@github.com>2020-04-07 14:07:42 (GMT)
commitd8acf0d9aae71d1897e8f91989bd8bfb4a9ef9c6 (patch)
tree5a5a4189b9908dfce74c24dcc34f512374f85458 /Objects
parent74e1b6b100719e11471e7e9949465655477926e2 (diff)
downloadcpython-d8acf0d9aae71d1897e8f91989bd8bfb4a9ef9c6.zip
cpython-d8acf0d9aae71d1897e8f91989bd8bfb4a9ef9c6.tar.gz
cpython-d8acf0d9aae71d1897e8f91989bd8bfb4a9ef9c6.tar.bz2
bpo-37388: Don't check encoding/errors during finalization (GH-19409)
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 9d51c8a..da17bfe 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -451,6 +451,12 @@ unicode_check_encoding_errors(const char *encoding, const char *errors)
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) {