]> granicus.if.org Git - python/commitdiff
unicode_result_wchar(): move the assert() to the "#ifdef Py_DEBUG" block
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 4 Oct 2012 00:32:58 +0000 (02:32 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 4 Oct 2012 00:32:58 +0000 (02:32 +0200)
Objects/unicodeobject.c

index 2481b96dda48067343de19545637dd8969b9fff5..98b10e95847f4be98fd0656debc9be75dc6613cb 100644 (file)
@@ -412,8 +412,6 @@ unicode_result_wchar(PyObject *unicode)
 #ifndef Py_DEBUG
     Py_ssize_t len;
 
-    assert(Py_REFCNT(unicode) == 1);
-
     len = _PyUnicode_WSTR_LENGTH(unicode);
     if (len == 0) {
         Py_INCREF(unicode_empty);
@@ -431,10 +429,12 @@ unicode_result_wchar(PyObject *unicode)
     }
 
     if (_PyUnicode_Ready(unicode) < 0) {
-        Py_XDECREF(unicode);
+        Py_DECREF(unicode);
         return NULL;
     }
 #else
+    assert(Py_REFCNT(unicode) == 1);
+
     /* don't make the result ready in debug mode to ensure that the caller
        makes the string ready before using it */
     assert(_PyUnicode_CheckConsistency(unicode, 1));