[Python-checkins] cpython: Fix _warnings.c: make the filename string ready

victor.stinner python-checkins at python.org
Thu Oct 6 02:37:42 CEST 2011


http://hg.python.org/cpython/rev/b1e5ade81097
changeset:   72716:b1e5ade81097
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Thu Oct 06 02:34:51 2011 +0200
summary:
  Fix _warnings.c: make the filename string ready

files:
  Python/_warnings.c |  13 ++++++++++---
  1 files changed, 10 insertions(+), 3 deletions(-)


diff --git a/Python/_warnings.c b/Python/_warnings.c
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -497,9 +497,16 @@
     /* Setup filename. */
     *filename = PyDict_GetItemString(globals, "__file__");
     if (*filename != NULL && PyUnicode_Check(*filename)) {
-        Py_ssize_t len = PyUnicode_GetSize(*filename);
-        int kind = PyUnicode_KIND(*filename);
-        void *data = PyUnicode_DATA(*filename);
+        Py_ssize_t len;
+        int kind;
+        void *data;
+
+        if (PyUnicode_READY(*filename))
+            goto handle_error;
+
+        len = PyUnicode_GetSize(*filename);
+        kind = PyUnicode_KIND(*filename);
+        data = PyUnicode_DATA(*filename);
 
         /* if filename.lower().endswith((".pyc", ".pyo")): */
         if (len >= 4 &&

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


More information about the Python-checkins mailing list