[Python-checkins] cpython: fileio_init() checks for failure on conversion to Py_UNICODE*

victor.stinner python-checkins at python.org
Thu Sep 29 23:18:54 CEST 2011


http://hg.python.org/cpython/rev/06d9652dbd67
changeset: 72536:06d9652dbd67
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Thu Sep 29 23:19:04 2011 +0200
summary:
 fileio_init() checks for failure on conversion to Py_UNICODE*
files:
 Modules/_io/fileio.c | 10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -259,9 +259,11 @@
 }
 
 #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 @@
 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);
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /