Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4fae54c

Browse files
author
Victor Stinner
committed
In release mode, PyUnicode_InternInPlace() does nothing if the input is NULL or
not a unicode, instead of failing with a fatal error. Use assertions in debug mode (provide better error messages).
1 parent 23e5668 commit 4fae54c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Objects/unicodeobject.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12893,17 +12893,21 @@ PyUnicode_InternInPlace(PyObject **p)
1289312893
{
1289412894
register PyUnicodeObject *s = (PyUnicodeObject *)(*p);
1289512895
PyObject *t;
12896+
#ifdef Py_DEBUG
12897+
assert(s != NULL);
12898+
assert(_PyUnicode_CHECK(s));
12899+
#else
1289612900
if (s == NULL || !PyUnicode_Check(s))
12897-
Py_FatalError(
12898-
"PyUnicode_InternInPlace: unicode strings only please!");
12901+
return;
12902+
#endif
1289912903
/* If it's a subclass, we don't really know what putting
1290012904
it in the interned dict might do. */
1290112905
if (!PyUnicode_CheckExact(s))
1290212906
return;
1290312907
if (PyUnicode_CHECK_INTERNED(s))
1290412908
return;
1290512909
if (PyUnicode_READY(s) == -1) {
12906-
assert(0 && "ready fail in intern...");
12910+
assert(0 && "PyUnicode_READY fail in PyUnicode_InternInPlace");
1290712911
return;
1290812912
}
1290912913
if (interned == NULL) {

0 commit comments

Comments
 (0)