Skip to content

Commit 9aa31d5

Browse files
committed
Fixes incorrect use of GetLastError where errno should be used.
2 parents 76c95a0 + 41e7244 commit 9aa31d5

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎Python/fileutils.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ get_inheritable(int fd, int raise)
733733
handle = (HANDLE)_get_osfhandle(fd);
734734
if (handle == INVALID_HANDLE_VALUE) {
735735
if (raise)
736-
PyErr_SetFromWindowsErr(0);
736+
PyErr_SetFromErrno(PyExc_OSError);
737737
return -1;
738738
}
739739

@@ -788,10 +788,10 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
788788

789789
if (atomic_flag_works != NULL && !inheritable) {
790790
if (*atomic_flag_works == -1) {
791-
int inheritable = get_inheritable(fd, raise);
792-
if (inheritable == -1)
791+
int isInheritable = get_inheritable(fd, raise);
792+
if (isInheritable == -1)
793793
return -1;
794-
*atomic_flag_works = !inheritable;
794+
*atomic_flag_works = !isInheritable;
795795
}
796796

797797
if (*atomic_flag_works)
@@ -808,7 +808,7 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
808808
handle = (HANDLE)_get_osfhandle(fd);
809809
if (handle == INVALID_HANDLE_VALUE) {
810810
if (raise)
811-
PyErr_SetFromWindowsErr(0);
811+
PyErr_SetFromErrno(PyExc_OSError);
812812
return -1;
813813
}
814814

@@ -1167,7 +1167,7 @@ _Py_dup(int fd)
11671167
#ifdef MS_WINDOWS
11681168
handle = (HANDLE)_get_osfhandle(fd);
11691169
if (handle == INVALID_HANDLE_VALUE) {
1170-
PyErr_SetFromWindowsErr(0);
1170+
PyErr_SetFromErrno(PyExc_OSError);
11711171
return -1;
11721172
}
11731173

0 commit comments

Comments
 (0)