bpo-36935: Remove usage of the deprecated PyErr_SetFromWindowsErrWithUnicodeFilename() (GH-13355)

In e895de3e7f, the
deprecated function PyErr_SetFromWindowsErrWithUnicodeFilename() was
added in two functions in Modules/_winapi.c. This function was
deprecated in 3.3.
This commit is contained in:
Zackery Spytz 2019-05-30 01:58:50 -06:00 committed by Victor Stinner
parent bee31ce775
commit eda385c0dc
1 changed files with 6 additions and 2 deletions

View File

@ -508,7 +508,9 @@ _winapi_CreateFileMapping_impl(PyObject *module, HANDLE file_handle,
Py_END_ALLOW_THREADS
if (handle == NULL) {
PyErr_SetFromWindowsErrWithUnicodeFilename(0, name);
PyObject *temp = PyUnicode_FromWideChar(name, -1);
PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, 0, temp);
Py_XDECREF(temp);
handle = INVALID_HANDLE_VALUE;
}
@ -1405,7 +1407,9 @@ _winapi_OpenFileMapping_impl(PyObject *module, DWORD desired_access,
Py_END_ALLOW_THREADS
if (handle == NULL) {
PyErr_SetFromWindowsErrWithUnicodeFilename(0, name);
PyObject *temp = PyUnicode_FromWideChar(name, -1);
PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, 0, temp);
Py_XDECREF(temp);
handle = INVALID_HANDLE_VALUE;
}