mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
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).
This commit is contained in:
parent
76df43de30
commit
292c835548
5 changed files with 199 additions and 108 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue