mirror of
https://github.com/python/cpython.git
synced 2025-12-05 00:52:25 +00:00
bpo-34563: Fix for invalid assert on big output of multiprocessing.Process (GH-9027)
Fix for invalid assert on big output of multiprocessing.Process.
This commit is contained in:
parent
7917aadb3e
commit
266f4904a2
3 changed files with 10 additions and 9 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
On Windows, fix multiprocessing.Connection for very large read: fix _winapi.PeekNamedPipe() and _winapi.ReadFile() for read larger than INT_MAX (usually 2^31-1).
|
||||||
|
|
@ -1338,7 +1338,7 @@ _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size)
|
||||||
}
|
}
|
||||||
if (_PyBytes_Resize(&buf, nread))
|
if (_PyBytes_Resize(&buf, nread))
|
||||||
return NULL;
|
return NULL;
|
||||||
return Py_BuildValue("Nii", buf, navail, nleft);
|
return Py_BuildValue("NII", buf, navail, nleft);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
|
@ -1347,7 +1347,7 @@ _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size)
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
return PyErr_SetExcFromWindowsErr(PyExc_OSError, 0);
|
return PyErr_SetExcFromWindowsErr(PyExc_OSError, 0);
|
||||||
}
|
}
|
||||||
return Py_BuildValue("ii", navail, nleft);
|
return Py_BuildValue("II", navail, nleft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1355,14 +1355,14 @@ _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size)
|
||||||
_winapi.ReadFile
|
_winapi.ReadFile
|
||||||
|
|
||||||
handle: HANDLE
|
handle: HANDLE
|
||||||
size: int
|
size: DWORD
|
||||||
overlapped as use_overlapped: bool(accept={int}) = False
|
overlapped as use_overlapped: bool(accept={int}) = False
|
||||||
[clinic start generated code]*/
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_winapi_ReadFile_impl(PyObject *module, HANDLE handle, int size,
|
_winapi_ReadFile_impl(PyObject *module, HANDLE handle, DWORD size,
|
||||||
int use_overlapped)
|
int use_overlapped)
|
||||||
/*[clinic end generated code: output=492029ca98161d84 input=3f0fde92f74de59a]*/
|
/*[clinic end generated code: output=d3d5b44a8201b944 input=08c439d03a11aac5]*/
|
||||||
{
|
{
|
||||||
DWORD nread;
|
DWORD nread;
|
||||||
PyObject *buf;
|
PyObject *buf;
|
||||||
|
|
|
||||||
8
Modules/clinic/_winapi.c.h
generated
8
Modules/clinic/_winapi.c.h
generated
|
|
@ -673,7 +673,7 @@ PyDoc_STRVAR(_winapi_ReadFile__doc__,
|
||||||
{"ReadFile", (PyCFunction)_winapi_ReadFile, METH_FASTCALL|METH_KEYWORDS, _winapi_ReadFile__doc__},
|
{"ReadFile", (PyCFunction)_winapi_ReadFile, METH_FASTCALL|METH_KEYWORDS, _winapi_ReadFile__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_winapi_ReadFile_impl(PyObject *module, HANDLE handle, int size,
|
_winapi_ReadFile_impl(PyObject *module, HANDLE handle, DWORD size,
|
||||||
int use_overlapped);
|
int use_overlapped);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
@ -681,9 +681,9 @@ _winapi_ReadFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
static const char * const _keywords[] = {"handle", "size", "overlapped", NULL};
|
static const char * const _keywords[] = {"handle", "size", "overlapped", NULL};
|
||||||
static _PyArg_Parser _parser = {"" F_HANDLE "i|i:ReadFile", _keywords, 0};
|
static _PyArg_Parser _parser = {"" F_HANDLE "k|i:ReadFile", _keywords, 0};
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
int size;
|
DWORD size;
|
||||||
int use_overlapped = 0;
|
int use_overlapped = 0;
|
||||||
|
|
||||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||||
|
|
@ -941,4 +941,4 @@ _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=ec7f36eb7efc9d00 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=baaf3d379b91be0a input=a9049054013a1b77]*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue