Commit dc555400 authored by Victor Stinner's avatar Victor Stinner

Issue #9015, #9611: stdprinter.write() clamps the length to 2^31-1 on Windows

parent 0fcab4a3
...@@ -12,8 +12,8 @@ Core and Builtins ...@@ -12,8 +12,8 @@ Core and Builtins
doesn't have PY_SSIZE_T_CLEAN define and the size doesn't fit in an int doesn't have PY_SSIZE_T_CLEAN define and the size doesn't fit in an int
(length bigger than 2^31-1 bytes). (length bigger than 2^31-1 bytes).
- Issue #9015, #9611: FileIO.readinto(), FileIO.write() and os.write() clamp - Issue #9015, #9611: FileIO.readinto(), FileIO.write(), os.write() and
the length to 2^31-1 on Windows. stdprinter.write() clamp the length to 2^31-1 on Windows.
- Issue #8278: On Windows and with a NTFS filesystem, os.stat() and os.utime() - Issue #8278: On Windows and with a NTFS filesystem, os.stat() and os.utime()
can now handle dates after 2038. can now handle dates after 2038.
......
...@@ -344,7 +344,7 @@ stdprinter_new(PyTypeObject *type, PyObject *args, PyObject *kews) ...@@ -344,7 +344,7 @@ stdprinter_new(PyTypeObject *type, PyObject *args, PyObject *kews)
} }
static int static int
fileio_init(PyObject *self, PyObject *args, PyObject *kwds) stdprinter_init(PyObject *self, PyObject *args, PyObject *kwds)
{ {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"cannot create 'stderrprinter' instances"); "cannot create 'stderrprinter' instances");
...@@ -390,7 +390,13 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args) ...@@ -390,7 +390,13 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
errno = 0; errno = 0;
#if defined(MS_WIN64) || defined(MS_WINDOWS)
if (n > INT_MAX)
n = INT_MAX;
n = write(self->fd, c, (int)n);
#else
n = write(self->fd, c, n); n = write(self->fd, c, n);
#endif
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (n < 0) { if (n < 0) {
...@@ -509,7 +515,7 @@ PyTypeObject PyStdPrinter_Type = { ...@@ -509,7 +515,7 @@ PyTypeObject PyStdPrinter_Type = {
0, /* tp_descr_get */ 0, /* tp_descr_get */
0, /* tp_descr_set */ 0, /* tp_descr_set */
0, /* tp_dictoffset */ 0, /* tp_dictoffset */
fileio_init, /* tp_init */ stdprinter_init, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */ PyType_GenericAlloc, /* tp_alloc */
stdprinter_new, /* tp_new */ stdprinter_new, /* tp_new */
PyObject_Del, /* tp_free */ PyObject_Del, /* tp_free */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment