[Python-checkins] cpython: unicode_result_wchar(): move the assert() to the "#ifdef Py_DEBUG" block

victor.stinner python-checkins at python.org
Thu Oct 4 02:40:50 CEST 2012


http://hg.python.org/cpython/rev/afe4b2921bb7
changeset:   79438:afe4b2921bb7
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Oct 04 02:32:58 2012 +0200
summary:
  unicode_result_wchar(): move the assert() to the "#ifdef Py_DEBUG" block

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


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -412,8 +412,6 @@
 #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 @@
     }
 
     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));

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


More information about the Python-checkins mailing list