[Python-checkins] cpython: In release mode, PyUnicode_InternInPlace() does nothing if the input is NULL or

victor.stinner python-checkins at python.org
Mon Oct 3 04:02:37 CEST 2011


http://hg.python.org/cpython/rev/6ca9bb281c37
changeset:   72602:6ca9bb281c37
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Mon Oct 03 02:01:52 2011 +0200
summary:
  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).

files:
  Objects/unicodeobject.c |  10 +++++++---
  1 files changed, 7 insertions(+), 3 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -12893,9 +12893,13 @@
 {
     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 @@
     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) {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list