Skip to content

Commit a3ded44

Browse files
committed
Add dup()
1 parent b9520d5 commit a3ded44

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Python/fileutils.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# include <winioctl.h> // FILE_DEVICE_* constants
1616
# include "pycore_fileutils_windows.h" // FILE_STAT_BASIC_INFORMATION
1717
# define fdopen _fdopen
18+
# define dup _dup
1819
# if defined(MS_WINDOWS_GAMES) && !defined(MS_WINDOWS_DESKTOP)
1920
# define PATHCCH_ALLOW_LONG_PATHS 0x01
2021
# else
@@ -2063,7 +2064,8 @@ _Py_write_noraise(int fd, const void *buf, size_t count)
20632064
int
20642065
_Py_fdprintf(int fd, const char *fmt, ...)
20652066
{
2066-
FILE *handle = fdopen(fd, "a");
2067+
int newfd = dup(fd);
2068+
FILE *handle = fdopen(newfd, "a");
20672069
va_list vargs;
20682070
va_start(vargs, fmt);
20692071
int res = vfprintf(handle, fmt, vargs);

0 commit comments

Comments
 (0)