summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-07-25 16:37:51 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2002-07-25 16:37:51 (GMT)
commit825e47b655623dff7ca515b28fe5d7b0ecfe7ad1 (patch)
treefeb7dbd40bf54ec26294e6881dbb4eb807933c82 /Modules
parentead36d787434d60cdd697df8debf552cc6d9888c (diff)
downloadcpython-825e47b655623dff7ca515b28fe5d7b0ecfe7ad1.zip
cpython-825e47b655623dff7ca515b28fe5d7b0ecfe7ad1.tar.gz
cpython-825e47b655623dff7ca515b28fe5d7b0ecfe7ad1.tar.bz2
Put checks for error returns in the right place.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 39809f4..d7354ba 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -2475,9 +2475,13 @@ socket_ntohl(PyObject *self, PyObject *arg)
if (PyInt_Check(arg)) {
x = PyInt_AS_LONG(arg);
+ if (x == (unsigned long) -1 && PyErr_Occurred())
+ return NULL;
}
else if (PyLong_Check(arg)) {
x = PyLong_AsUnsignedLong(arg);
+ if (x == (unsigned long) -1 && PyErr_Occurred())
+ return NULL;
#if SIZEOF_LONG > 4
{
unsigned long y;
@@ -2530,9 +2534,13 @@ socket_htonl(PyObject *self, PyObject *arg)
if (PyInt_Check(arg)) {
x = PyInt_AS_LONG(arg);
+ if (x == (unsigned long) -1 && PyErr_Occurred())
+ return NULL;
}
else if (PyLong_Check(arg)) {
x = PyLong_AsUnsignedLong(arg);
+ if (x == (unsigned long) -1 && PyErr_Occurred())
+ return NULL;
#if SIZEOF_LONG > 4
{
unsigned long y;
@@ -2549,8 +2557,6 @@ socket_htonl(PyObject *self, PyObject *arg)
return PyErr_Format(PyExc_TypeError,
"expected int/long, %s found",
arg->ob_type->tp_name);
- if (x == (unsigned long) -1 && PyErr_Occurred())
- return NULL;
return PyInt_FromLong(htonl(x));
}