mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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).
This commit is contained in:
parent
23e5668214
commit
4fae54cb0e
1 changed files with 7 additions and 3 deletions
|
@ -12893,9 +12893,13 @@ PyUnicode_InternInPlace(PyObject **p)
|
||||||
{
|
{
|
||||||
register PyUnicodeObject *s = (PyUnicodeObject *)(*p);
|
register PyUnicodeObject *s = (PyUnicodeObject *)(*p);
|
||||||
PyObject *t;
|
PyObject *t;
|
||||||
|
#ifdef Py_DEBUG
|
||||||
|
assert(s != NULL);
|
||||||
|
assert(_PyUnicode_CHECK(s));
|
||||||
|
#else
|
||||||
if (s == NULL || !PyUnicode_Check(s))
|
if (s == NULL || !PyUnicode_Check(s))
|
||||||
Py_FatalError(
|
return;
|
||||||
"PyUnicode_InternInPlace: unicode strings only please!");
|
#endif
|
||||||
/* If it's a subclass, we don't really know what putting
|
/* If it's a subclass, we don't really know what putting
|
||||||
it in the interned dict might do. */
|
it in the interned dict might do. */
|
||||||
if (!PyUnicode_CheckExact(s))
|
if (!PyUnicode_CheckExact(s))
|
||||||
|
@ -12903,7 +12907,7 @@ PyUnicode_InternInPlace(PyObject **p)
|
||||||
if (PyUnicode_CHECK_INTERNED(s))
|
if (PyUnicode_CHECK_INTERNED(s))
|
||||||
return;
|
return;
|
||||||
if (PyUnicode_READY(s) == -1) {
|
if (PyUnicode_READY(s) == -1) {
|
||||||
assert(0 && "ready fail in intern...");
|
assert(0 && "PyUnicode_READY fail in PyUnicode_InternInPlace");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (interned == NULL) {
|
if (interned == NULL) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue