[Python-checkins] cpython: Add DONT_MAKE_RESULT_READY to unicodeobject.c to help detecting bugs

victor.stinner python-checkins at python.org
Tue Oct 4 20:52:53 CEST 2011


http://hg.python.org/cpython/rev/411c0734cf48
changeset:   72677:411c0734cf48
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Tue Oct 04 20:05:46 2011 +0200
summary:
  Add DONT_MAKE_RESULT_READY to unicodeobject.c to help detecting bugs

Use also _PyUnicode_READY_REPLACE() when it's applicable.

files:
  Objects/unicodeobject.c |  30 +++++++++++++++++++++++++++-
  1 files changed, 28 insertions(+), 2 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2625,10 +2625,12 @@
         goto onError;
     }
     Py_DECREF(buffer);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&unicode)) {
         Py_DECREF(unicode);
         return NULL;
     }
+#endif
     return unicode;
 
   onError:
@@ -3674,10 +3676,12 @@
 
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&unicode)) {
         Py_DECREF(unicode);
         return NULL;
     }
+#endif
     return (PyObject *)unicode;
 
   onError:
@@ -4244,10 +4248,12 @@
 
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&unicode)) {
         Py_DECREF(unicode);
         return NULL;
     }
+#endif
     return (PyObject *)unicode;
 
   onError:
@@ -4747,10 +4753,12 @@
 
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&unicode)) {
         Py_DECREF(unicode);
         return NULL;
     }
+#endif
     return (PyObject *)unicode;
 
   onError:
@@ -5145,10 +5153,12 @@
 
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&unicode)) {
         Py_DECREF(unicode);
         return NULL;
     }
+#endif
     return (PyObject *)unicode;
 
   onError:
@@ -5604,10 +5614,12 @@
     }
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&v)) {
         Py_DECREF(v);
         return NULL;
     }
+#endif
     return (PyObject *)v;
 
   ucnhashError:
@@ -5905,10 +5917,12 @@
         goto onError;
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&v)) {
         Py_DECREF(v);
         return NULL;
     }
+#endif
     return (PyObject *)v;
 
   onError:
@@ -6093,10 +6107,12 @@
         goto onError;
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&v)) {
         Py_DECREF(v);
         return NULL;
     }
+#endif
     return (PyObject *)v;
 
   onError:
@@ -6519,10 +6535,12 @@
             goto onError;
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&v)) {
         Py_DECREF(v);
         return NULL;
     }
+#endif
     return (PyObject *)v;
 
   onError:
@@ -6713,10 +6731,12 @@
         goto retry;
     }
 #endif
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&v)) {
         Py_DECREF(v);
         return NULL;
     }
+#endif
     return (PyObject *)v;
 }
 
@@ -7012,10 +7032,12 @@
             goto onError;
     Py_XDECREF(errorHandler);
     Py_XDECREF(exc);
+#ifndef DONT_MAKE_RESULT_READY
     if (_PyUnicode_READY_REPLACE(&v)) {
         Py_DECREF(v);
         return NULL;
     }
+#endif
     return (PyObject *)v;
 
   onError:
@@ -8057,10 +8079,12 @@
                 p[i] = '0' + decimal;
         }
     }
-    if (PyUnicode_READY((PyUnicodeObject*)result) == -1) {
+#ifndef DONT_MAKE_RESULT_READY
+    if (_PyUnicode_READY_REPLACE(&result)) {
         Py_DECREF(result);
         return NULL;
     }
+#endif
     return result;
 }
 /* --- Decimal Encoder ---------------------------------------------------- */
@@ -10265,10 +10289,12 @@
         }
     }
     assert (j == PyUnicode_GET_LENGTH(u));
-    if (PyUnicode_READY(u)) {
+#ifndef DONT_MAKE_RESULT_READY
+    if (_PyUnicode_READY_REPLACE(&u)) {
         Py_DECREF(u);
         return NULL;
     }
+#endif
     return (PyObject*) u;
 
   overflow:

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


More information about the Python-checkins mailing list