mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-20 03:52:25 +03:00
Fix libxml_PyFileGet with stdout on macOS
macOS returns O_RDWR for standard file descriptors, but fails to write to stdout or stderr when opened with fdopen(dup_fd, "rw").
This commit is contained in:
@@ -154,6 +154,19 @@ libxml_PyFileGet(PyObject *f) {
|
|||||||
if (!is_write && !is_read) /* also happens if we did not load or run NtQueryInformationFile() successfully */
|
if (!is_write && !is_read) /* also happens if we did not load or run NtQueryInformationFile() successfully */
|
||||||
return(NULL);
|
return(NULL);
|
||||||
#else
|
#else
|
||||||
|
/*
|
||||||
|
* macOS returns O_RDWR for standard streams, but fails to write to
|
||||||
|
* stdout or stderr when opened with fdopen(dup_fd, "rw").
|
||||||
|
*/
|
||||||
|
switch (fd) {
|
||||||
|
case STDIN_FILENO:
|
||||||
|
mode = "r";
|
||||||
|
break;
|
||||||
|
case STDOUT_FILENO:
|
||||||
|
case STDERR_FILENO:
|
||||||
|
mode = "w";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
/*
|
/*
|
||||||
* Get the flags on the fd to understand how it was opened
|
* Get the flags on the fd to understand how it was opened
|
||||||
*/
|
*/
|
||||||
@@ -180,6 +193,7 @@ libxml_PyFileGet(PyObject *f) {
|
|||||||
default:
|
default:
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user