Eryk Sun <eryk...@gmail.com> added the comment:

This was my fault for recommending PyErr_SetFromWindowsErrWithUnicodeFilename 
without checking the header for deprecation. 

PyErr_SetFromWindowsErrWithUnicodeFilename is an internal function (added for 
PEP 277, circa 2.4), which was never documented in the C API. I don't follow 
why Serhiy deprecated it in 2016, since at the same time he updated it to use 
PyUnicode_FromWideChar instead of PyUnicode_FromUnicode. I see no fundamental 
difference in terms of resource usage between it and 
PyErr_SetExcFromWindowsErrWithFilename, which instead calls 
PyUnicode_DecodeFSDefault.

In this case, the section object (file mapping) name is useful information in 
the exception. If the deprecation isn't lifted, it puts the onus on us to 
implement this functionality -- i.e. PyUnicode_FromWideChar, 
PyErr_SetExcFromWindowsErrWithFilenameObjects, Py_XDECREF. Or maybe add a new 
PyErr_SetExcFromWindowsErrWithWideCharFilename function that takes a `const 
wchar_t *` string, and document it in the C API.

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36935>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to