Issue 36935: bpo-35813 introduced usage of the deprecated PyErr_SetFromWindowsErrWithUnicodeFilename() function (original) (raw)

Issue36935

Created on 2019-05-16 05:13 by ZackerySpytz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13355 merged ZackerySpytz,2019-05-16 05:17
Messages (5)
msg342626 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-05-16 05:13
In e895de3e7f3cc2f7213b87621cfe9812ea4343f0 / 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.
msg342628 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2019-05-16 08:06
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.
msg343819 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-05-28 21:18
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().
msg343847 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2019-05-29 01:17
> I think it would be best to replace the two calls with > PyErr_SetFromWindowsErr(0) (for now). For now it can at least be implemented inline. For example: if (handle == NULL) { PyObject *temp = name ? PyUnicode_FromWideChar(name, -1) : NULL; PyErr_SetExcFromWindowsErrWithFilenameObjects(PyExc_OSError, 0, temp, NULL); Py_XDECREF(temp); handle = INVALID_HANDLE_VALUE; } 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.
msg343956 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-30 07:59
New changeset eda385c0dca62f97a8ae80feb57c2a51df3c807f by Victor Stinner (Zackery Spytz) in branch 'master': bpo-36935: Remove usage of the deprecated PyErr_SetFromWindowsErrWithUnicodeFilename() (GH-13355) https://github.com/python/cpython/commit/eda385c0dca62f97a8ae80feb57c2a51df3c807f
History
Date User Action Args
2022-04-11 14:59:15 admin set github: 81116
2019-06-05 12:07:33 vstinner set status: open -> closedresolution: fixedstage: patch review -> resolved
2019-05-30 07:59:07 vstinner set messages: +
2019-05-29 01:17:01 eryksun set messages: +
2019-05-28 21🔞28 ZackerySpytz set nosy: + vstinner, serhiy.storchakamessages: +
2019-05-16 08:06:17 eryksun set nosy: + eryksunmessages: +
2019-05-16 05:17:16 ZackerySpytz set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest13265>
2019-05-16 05:13:20 ZackerySpytz create