summaryrefslogtreecommitdiffstats
path: root/Include/fileutils.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/fileutils.h')
-rw-r--r--Include/fileutils.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/Include/fileutils.h b/Include/fileutils.h
index f0a8e2c..232d966 100644
--- a/Include/fileutils.h
+++ b/Include/fileutils.h
@@ -81,6 +81,19 @@ PyAPI_FUNC(int) _Py_EncodeLocaleEx(
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
+#if defined(MS_WINDOWS) || defined(__APPLE__)
+ /* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611).
+ On macOS 10.13, read() and write() with more than INT_MAX bytes
+ fail with EINVAL (bpo-24658). */
+# define _PY_READ_MAX INT_MAX
+# define _PY_WRITE_MAX INT_MAX
+#else
+ /* write() should truncate the input to PY_SSIZE_T_MAX bytes,
+ but it's safer to do it ourself to have a portable behaviour */
+# define _PY_READ_MAX PY_SSIZE_T_MAX
+# define _PY_WRITE_MAX PY_SSIZE_T_MAX
+#endif
+
#ifdef MS_WINDOWS
struct _Py_stat_struct {
unsigned long st_dev;