diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-03-17 21:46:17 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-03-17 21:46:17 (GMT) |
commit | fee6684f3c26b1aa51a3688ad324747a770a9bb2 (patch) | |
tree | 9415e67169abd0258741e4341e6089568a4f6699 /Modules/socketmodule.c | |
parent | 8e7496785563411d0488ffa3718b265ee24322d3 (diff) | |
parent | 9befeb3743aaaee6aef036b5a1092cc02d9b4dfa (diff) | |
download | cpython-fee6684f3c26b1aa51a3688ad324747a770a9bb2.zip cpython-fee6684f3c26b1aa51a3688ad324747a770a9bb2.tar.gz cpython-fee6684f3c26b1aa51a3688ad324747a770a9bb2.tar.bz2 |
Issue #5421: merge fix
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 617295a..1631363 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2747,17 +2747,28 @@ sock_sendto(PySocketSockObject *s, PyObject *args) Py_buffer pbuf; PyObject *addro; char *buf; - Py_ssize_t len; + Py_ssize_t len, arglen; sock_addr_t addrbuf; int addrlen, n = -1, flags, timeout; flags = 0; - if (!PyArg_ParseTuple(args, "y*O:sendto", &pbuf, &addro)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "y*iO:sendto", - &pbuf, &flags, &addro)) - return NULL; + arglen = PyTuple_Size(args); + switch (arglen) { + case 2: + PyArg_ParseTuple(args, "y*O:sendto", &pbuf, &addro); + break; + case 3: + PyArg_ParseTuple(args, "y*iO:sendto", + &pbuf, &flags, &addro); + break; + default: + PyErr_Format(PyExc_TypeError, + "sendto() takes 2 or 3 arguments (%d given)", + arglen); } + if (PyErr_Occurred()) + return NULL; + buf = pbuf.buf; len = pbuf.len; |