Skip to content

Commit eda385c

Browse files
ZackerySpytzvstinner
authored andcommitted
bpo-36935: Remove usage of the deprecated PyErr_SetFromWindowsErrWithUnicodeFilename() (GH-13355)
In e895de3, the deprecated function PyErr_SetFromWindowsErrWithUnicodeFilename() was added in two functions in Modules/_winapi.c. This function was deprecated in 3.3.
1 parent bee31ce commit eda385c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Modules/_winapi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,9 @@ _winapi_CreateFileMapping_impl(PyObject *module, HANDLE file_handle,
508508
Py_END_ALLOW_THREADS
509509

510510
if (handle == NULL) {
511-
PyErr_SetFromWindowsErrWithUnicodeFilename(0, name);
511+
PyObject *temp = PyUnicode_FromWideChar(name, -1);
512+
PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, 0, temp);
513+
Py_XDECREF(temp);
512514
handle = INVALID_HANDLE_VALUE;
513515
}
514516

@@ -1405,7 +1407,9 @@ _winapi_OpenFileMapping_impl(PyObject *module, DWORD desired_access,
14051407
Py_END_ALLOW_THREADS
14061408

14071409
if (handle == NULL) {
1408-
PyErr_SetFromWindowsErrWithUnicodeFilename(0, name);
1410+
PyObject *temp = PyUnicode_FromWideChar(name, -1);
1411+
PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, 0, temp);
1412+
Py_XDECREF(temp);
14091413
handle = INVALID_HANDLE_VALUE;
14101414
}
14111415

0 commit comments

Comments
 (0)