diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-29 21:19:04 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-29 21:19:04 (GMT) |
commit | fe9a861e740d2627618f1d8d7731d36946bf6994 (patch) | |
tree | bfec15cc9c7d894f1ec3bb70543eab8167a62900 /Modules | |
parent | ef17f12a393b4d7653066f34e0207ef8f46065c4 (diff) | |
download | cpython-fe9a861e740d2627618f1d8d7731d36946bf6994.zip cpython-fe9a861e740d2627618f1d8d7731d36946bf6994.tar.gz cpython-fe9a861e740d2627618f1d8d7731d36946bf6994.tar.bz2 |
fileio_init() checks for failure on conversion to Py_UNICODE*
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/fileio.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 3de1ff5..2bf8933 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -259,9 +259,11 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) } #ifdef MS_WINDOWS - if (PyUnicode_Check(nameobj)) - widename = PyUnicode_AS_UNICODE(nameobj); - if (widename == NULL) + if (PyUnicode_Check(nameobj)) { + widename = PyUnicode_AsUnicode(nameobj); + if (widename == NULL) + return -1; + } else #endif if (fd < 0) { @@ -378,7 +380,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) if (self->fd < 0) { #ifdef MS_WINDOWS if (widename != NULL) - PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename); + PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj); else #endif PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); |