mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
bpo-37549: os.dup() fails for standard streams on Windows 7 (GH-15389)
This commit is contained in:
parent
8f080b0995
commit
5be666010e
3 changed files with 14 additions and 1 deletions
|
@ -1134,11 +1134,18 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
|
|||
flags = HANDLE_FLAG_INHERIT;
|
||||
else
|
||||
flags = 0;
|
||||
if (!SetHandleInformation(handle, HANDLE_FLAG_INHERIT, flags)) {
|
||||
|
||||
/* This check can be removed once support for Windows 7 ends. */
|
||||
#define CONSOLE_PSEUDOHANDLE(handle) (((ULONG_PTR)(handle) & 0x3) == 0x3 && \
|
||||
GetFileType(handle) == FILE_TYPE_CHAR)
|
||||
|
||||
if (!CONSOLE_PSEUDOHANDLE(handle) &&
|
||||
!SetHandleInformation(handle, HANDLE_FLAG_INHERIT, flags)) {
|
||||
if (raise)
|
||||
PyErr_SetFromWindowsErr(0);
|
||||
return -1;
|
||||
}
|
||||
#undef CONSOLE_PSEUDOHANDLE
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue