[issue20517] Support errors with two filenames for errno exceptions

STINNER Victor report at bugs.python.org
Mon Feb 10 12:10:26 CET 2014


STINNER Victor added the comment:

"And you should avoid passing raw bytes string to build an error message, you probably has the Python object version of the filename somewhere in your code."

Oh, I remember the reason why char* must not be used to build an OSError: on Windows, you should never try to decode a bytes filename, because it may raise a UnicodeDecodeError while you are trying to build an OSError. See issue #15478 for the rationale.

Just pass the original PyObject* you get in path_t. There is even an unit test to ensure that OSError.filename is the original name: OSErrorTests.test_oserror_filename() in test_os.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20517>
_______________________________________


More information about the Python-bugs-list mailing list