]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix _warnings.c: make the filename string ready
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 6 Oct 2011 00:34:51 +0000 (02:34 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 6 Oct 2011 00:34:51 +0000 (02:34 +0200)
Python/_warnings.c

index 2bcca91fa6502472e7c0f2f0d1f6cc55ceed2ab7..792e3ed6df12f78590fe2d5bfc416c1a374a6930 100644 (file)
@@ -497,9 +497,16 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
     /* 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 &&