diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-06 00:34:51 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-06 00:34:51 (GMT) |
commit | b62a7b268af8d58e5565b44a38c923917d7b62fe (patch) | |
tree | 0669ae2175fe4dc2a9519715f174a697675089ad /Python | |
parent | 1d4b35f4e569a3addf177cff744d856d3da71470 (diff) | |
download | cpython-b62a7b268af8d58e5565b44a38c923917d7b62fe.zip cpython-b62a7b268af8d58e5565b44a38c923917d7b62fe.tar.gz cpython-b62a7b268af8d58e5565b44a38c923917d7b62fe.tar.bz2 |
Fix _warnings.c: make the filename string ready
Diffstat (limited to 'Python')
-rw-r--r-- | Python/_warnings.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 2bcca91..792e3ed 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -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 && |