]> granicus.if.org Git - python/commitdiff
bpo-36935: Remove usage of the deprecated PyErr_SetFromWindowsErrWithUnicodeFilename...
authorZackery Spytz <zspytz@gmail.com>
Thu, 30 May 2019 07:58:50 +0000 (01:58 -0600)
committerVictor Stinner <vstinner@redhat.com>
Thu, 30 May 2019 07:58:50 +0000 (09:58 +0200)
In e895de3e7f3cc2f7213b87621cfe9812ea4343f0, the
deprecated function PyErr_SetFromWindowsErrWithUnicodeFilename() was
added in two functions in Modules/_winapi.c. This function was
deprecated in 3.3.

Modules/_winapi.c

index 1317fc9a172c0d8bf7a838fee0615cf4488ffbe8..e9dcec6590b6cebafc3973378f2689a9c13f70de 100644 (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;
     }