]> granicus.if.org Git - python/commitdiff
Put checks for error returns in the right place.
authorJeremy Hylton <jeremy@alum.mit.edu>
Thu, 25 Jul 2002 16:37:51 +0000 (16:37 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Thu, 25 Jul 2002 16:37:51 +0000 (16:37 +0000)
Modules/socketmodule.c

index 39809f43fe0b8d549ca94930ffcc17cb9dc7545a..d7354ba1f1698c814c07b883443a1bb490a365af 100644 (file)
@@ -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));
 }