]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
In release mode, PyUnicode_InternInPlace() does nothing if the input is NULL or
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 3 Oct 2011 00:01:52 +0000 (02:01 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 3 Oct 2011 00:01:52 +0000 (02:01 +0200)
not a unicode, instead of failing with a fatal error.

Use assertions in debug mode (provide better error messages).

Objects/unicodeobject.c

index 3eec75aae0ca9f790332f62a93848c80a45b61da..29788b3c4106c4bd191f6d6c96986cc61cb3ce82 100644 (file)
@@ -12893,9 +12893,13 @@ PyUnicode_InternInPlace(PyObject **p)
 {
     register PyUnicodeObject *s = (PyUnicodeObject *)(*p);
     PyObject *t;
+#ifdef Py_DEBUG
+    assert(s != NULL);
+    assert(_PyUnicode_CHECK(s));
+#else
     if (s == NULL || !PyUnicode_Check(s))
-        Py_FatalError(
-            "PyUnicode_InternInPlace: unicode strings only please!");
+        return;
+#endif
     /* If it's a subclass, we don't really know what putting
        it in the interned dict might do. */
     if (!PyUnicode_CheckExact(s))
@@ -12903,7 +12907,7 @@ PyUnicode_InternInPlace(PyObject **p)
     if (PyUnicode_CHECK_INTERNED(s))
         return;
     if (PyUnicode_READY(s) == -1) {
-        assert(0 && "ready fail in intern...");
+        assert(0 && "PyUnicode_READY fail in PyUnicode_InternInPlace");
         return;
     }
     if (interned == NULL) {