Commit fe9a861e authored by Victor Stinner's avatar Victor Stinner

fileio_init() checks for failure on conversion to Py_UNICODE*

parent ef17f12a
...@@ -259,9 +259,11 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) ...@@ -259,9 +259,11 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
} }
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (PyUnicode_Check(nameobj)) if (PyUnicode_Check(nameobj)) {
widename = PyUnicode_AS_UNICODE(nameobj); widename = PyUnicode_AsUnicode(nameobj);
if (widename == NULL) if (widename == NULL)
return -1;
} else
#endif #endif
if (fd < 0) if (fd < 0)
{ {
...@@ -378,7 +380,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) ...@@ -378,7 +380,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
if (self->fd < 0) { if (self->fd < 0) {
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (widename != NULL) if (widename != NULL)
PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename); PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj);
else else
#endif #endif
PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment