Eryk Sun <[email protected]> added the comment:
It's still the case that we have to guess that a generic EINVAL (22) is
actually EPIPE. Low-level wrapper functions in Python/fileutils.c, such as
_Py_read() and _Py_write_impl(), should try to get a better error code by
calling Python's custom winerror_to_errno() mapping function on the CRT's
_doserrno value. For example:
_Py_read:
#ifdef MS_WINDOWS
n = read(fd, buf, (int)count);
if (n < 0 && errno == EINVAL) {
errno = winerror_to_errno(_doserrno);
}
_Py_write_impl:
#ifdef MS_WINDOWS
n = write(fd, buf, (int)count);
if (n < 0 && errno == EINVAL) {
errno = winerror_to_errno(_doserrno);
}
This maps ERROR_NO_DATA to EPIPE.
----------
title: When writing/closing a closed Popen.stdin, I get OSError vs.
BrokenPipeError randomly or depending on bufsize -> [Windows] I/O on a broken
pipe may raise an EINVAL OSError instead of BrokenPipeError
versions: +Python 3.10, Python 3.9 -Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35754>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com