You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bpo-35813 introduced usage of the deprecated PyErr_SetFromWindowsErrWithUnicodeFilename() function #81116
In e895de3 / bpo-35813, the deprecated function PyErr_SetFromWindowsErrWithUnicodeFilename() was added in two functions in Modules/_winapi.c. This function was deprecated in 3.3 (and all occurrences of it were removed). Also, if bpo-33407 is accepted, usage of this function will cause compiler warnings.
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.
ZackerySpytz commented on May 28, 2019
ZackerySpytzmannequin
MannequinAuthor
More actions
The PR for bpo-33407 has been merged, so two warnings are now emitted in Modules/_winapi.c. I think it would be best to replace the two calls with PyErr_SetFromWindowsErr(0) (for now).
Eryk, I think a discussion on python-dev would be necessary for something like PyErr_SetExcFromWindowsErrWithWideCharFilename().
I think undeprecating the two PyErr_ functions with a modified signature in 3.8 is okay since they were never in the documented API, never in the stable (limited) API, and Py_UNICODE has been a typedef for wchar_t since 3.3.
New changeset eda385c by Victor Stinner (Zackery Spytz) in branch 'master': bpo-36935: Remove usage of the deprecated PyErr_SetFromWindowsErrWithUnicodeFilename() (GH-13355) eda385c
Activity
ZackerySpytz commentedon May 16, 2019
In e895de3 / bpo-35813, the deprecated function PyErr_SetFromWindowsErrWithUnicodeFilename() was added in two functions in Modules/_winapi.c. This function was deprecated in 3.3 (and all occurrences of it were removed). Also, if bpo-33407 is accepted, usage of this function will cause compiler warnings.
See also bpo-19569.
eryksun commentedon May 16, 2019
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.ZackerySpytz commentedon May 28, 2019
The PR for bpo-33407 has been merged, so two warnings are now emitted in Modules/_winapi.c. I think it would be best to replace the two calls with PyErr_SetFromWindowsErr(0) (for now).
Eryk, I think a discussion on python-dev would be necessary for something like PyErr_SetExcFromWindowsErrWithWideCharFilename().
eryksun commentedon May 29, 2019
For now it can at least be implemented inline. For example:
I think undeprecating the two PyErr_ functions with a modified signature in 3.8 is okay since they were never in the documented API, never in the stable (limited) API, and Py_UNICODE has been a typedef for wchar_t since 3.3.
vstinner commentedon May 30, 2019
New changeset eda385c by Victor Stinner (Zackery Spytz) in branch 'master':
bpo-36935: Remove usage of the deprecated PyErr_SetFromWindowsErrWithUnicodeFilename() (GH-13355)
eda385c