Mercurial > cpython-lru_cache-weakref
diff Python/_warnings.c @ 72716:b1e5ade81097
Fix _warnings.c: make the filename string ready
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Thu, 06 Oct 2011 02:34:51 +0200 |
| parents | 8beaa9a37387 |
| children | 5e33219492bc |
line wrap: on
line diff
--- a/Python/_warnings.c Thu Oct 06 01:51:19 2011 +0200 +++ b/Python/_warnings.c Thu Oct 06 02:34:51 2011 +0200 @@ -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 &&
