summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-10-30 01:17:38 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-10-30 01:17:38 (GMT)
commit292c835548df618983043b9698d0dc8c34adea12 (patch)
tree11ae17b994b6eaaaf5625d05839ad16af03443f9 /Modules/_io
parent76df43de30f40b5cc1de9d36a5a083dd8bd8cb27 (diff)
downloadcpython-292c835548df618983043b9698d0dc8c34adea12.zip
cpython-292c835548df618983043b9698d0dc8c34adea12.tar.gz
cpython-292c835548df618983043b9698d0dc8c34adea12.tar.bz2
Issue #15478: Raising an OSError doesn't decode or encode the filename anymore
Pass the original filename argument to OSError constructor, instead of trying to encode it to or decode it from the filesystem encoding. This change avoids an additionnal UnicodeDecodeError on Windows if the filename cannot be decoded from the filesystem encoding (ANSI code page).
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/fileio.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 6e0bbee..beacd9f 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -391,12 +391,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
fd_is_own = 1;
if (self->fd < 0) {
-#ifdef MS_WINDOWS
- if (widename != NULL)
- PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj);
- else
-#endif
- PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
+ PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, nameobj);
goto error;
}
}