Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Side by Side Diff: Modules/socketmodule.c

Issue 28261: wrong error messages when using PyArg_ParseTuple to parse normal tuples
Patch Set: Created 3 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« Modules/overlapped.c ('K') | « Modules/overlapped.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Socket module */ 1 /* Socket module */
2 2
3 /* 3 /*
4 4
5 This module provides an interface to Berkeley socket IPC. 5 This module provides an interface to Berkeley socket IPC.
6 6
7 Limitations: 7 Limitations:
8 8
9 - Only AF_INET, AF_INET6 and AF_UNIX address families are supported in a 9 - Only AF_INET, AF_INET6 and AF_UNIX address families are supported in a
10 portable manner, though AF_PACKET, AF_NETLINK and AF_TIPC are supported 10 portable manner, though AF_PACKET, AF_NETLINK and AF_TIPC are supported
(...skipping 6061 matching lines...) Expand 10 before | Expand all | Expand 10 after
6072 PyObject *name; 6072 PyObject *name;
6073 6073
6074 flags = flowinfo = scope_id = 0; 6074 flags = flowinfo = scope_id = 0;
6075 if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags)) 6075 if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags))
6076 return NULL; 6076 return NULL;
6077 if (!PyTuple_Check(sa)) { 6077 if (!PyTuple_Check(sa)) {
6078 PyErr_SetString(PyExc_TypeError, 6078 PyErr_SetString(PyExc_TypeError,
6079 "getnameinfo() argument 1 must be a tuple"); 6079 "getnameinfo() argument 1 must be a tuple");
6080 return NULL; 6080 return NULL;
6081 } 6081 }
6082 if (!PyArg_ParseTuple(sa, "si|II", 6082 if (!PyArg_ParseTuple(sa,
6083 &hostp, &port, &flowinfo, &scope_id)) 6083 "si|II;getnameinfo: illegal sockaddr argument",
6084 &hostp, &port, &flowinfo, &scope_id)) {
6084 return NULL; 6085 return NULL;
6086 }
6085 if (flowinfo > 0xfffff) { 6087 if (flowinfo > 0xfffff) {
6086 PyErr_SetString(PyExc_OverflowError, 6088 PyErr_SetString(PyExc_OverflowError,
6087 "getsockaddrarg: flowinfo must be 0-1048575."); 6089 "getnameinfo: flowinfo must be 0-1048575.");
6088 return NULL; 6090 return NULL;
6089 } 6091 }
6090 PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port); 6092 PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
6091 memset(&hints, 0, sizeof(hints)); 6093 memset(&hints, 0, sizeof(hints));
6092 hints.ai_family = AF_UNSPEC; 6094 hints.ai_family = AF_UNSPEC;
6093 hints.ai_socktype = SOCK_DGRAM; /* make numeric port happy */ 6095 hints.ai_socktype = SOCK_DGRAM; /* make numeric port happy */
6094 hints.ai_flags = AI_NUMERICHOST; /* don't do any name resolution */ 6096 hints.ai_flags = AI_NUMERICHOST; /* don't do any name resolution */
6095 Py_BEGIN_ALLOW_THREADS 6097 Py_BEGIN_ALLOW_THREADS
6096 ACQUIRE_GETADDRINFO_LOCK 6098 ACQUIRE_GETADDRINFO_LOCK
6097 error = getaddrinfo(hostp, pbuf, &hints, &res); 6099 error = getaddrinfo(hostp, pbuf, &hints, &res);
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after
7742 return NULL; 7744 return NULL;
7743 memcpy(&packed_addr, src, sizeof(packed_addr)); 7745 memcpy(&packed_addr, src, sizeof(packed_addr));
7744 return strncpy(dst, inet_ntoa(packed_addr), size); 7746 return strncpy(dst, inet_ntoa(packed_addr), size);
7745 } 7747 }
7746 /* Should set errno to EAFNOSUPPORT */ 7748 /* Should set errno to EAFNOSUPPORT */
7747 return NULL; 7749 return NULL;
7748 } 7750 }
7749 7751
7750 #endif 7752 #endif
7751 #endif 7753 #endif
OLDNEW
« Modules/overlapped.c ('K') | « Modules/overlapped.c ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+