]> granicus.if.org Git - python/commitdiff
save(): Reformat tail end just for clarity.
authorTim Peters <tim.peters@gmail.com>
Thu, 13 Feb 2003 21:03:57 +0000 (21:03 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 13 Feb 2003 21:03:57 +0000 (21:03 +0000)
Modules/cPickle.c

index 6601290f4c273060fa2629f8daaf8b7c626636f7..c131e9ea06434a74b0b24c1f2692c7b99182d2c5 100644 (file)
@@ -2455,9 +2455,10 @@ save(Picklerobject *self, PyObject *args, int pers_save)
                goto finally;
        }
 
-       if ((__reduce__ = PyDict_GetItem(dispatch_table, (PyObject *)type))) {
+       assert(t == NULL);      /* just a reminder */
+       __reduce__ = PyDict_GetItem(dispatch_table, (PyObject *)type);
+       if (__reduce__ != NULL) {
                Py_INCREF(__reduce__);
-
                Py_INCREF(args);
                ARG_TUP(self, args);
                if (self->arg) {
@@ -2467,16 +2468,14 @@ save(Picklerobject *self, PyObject *args, int pers_save)
                if (! t) goto finally;
        }
        else {
-               PyErr_Clear();
-
-               if ((__reduce__ = PyObject_GetAttr(args, __reduce___str))) {
+               __reduce__ = PyObject_GetAttr(args, __reduce___str);
+               if (__reduce__ == NULL)
+                       PyErr_Clear();
+               else {
                        t = PyObject_Call(__reduce__, empty_tuple, NULL);
                        if (!t)
                                goto finally;
                }
-               else {
-                       PyErr_Clear();
-               }
        }
 
        if (t) {
@@ -2486,21 +2485,22 @@ save(Picklerobject *self, PyObject *args, int pers_save)
                }
 
                if (!PyTuple_Check(t)) {
-                       cPickle_ErrFormat(PicklingError, "Value returned by %s must "
-                                         "be a tuple", "O", __reduce__);
+                       cPickle_ErrFormat(PicklingError, "Value returned by "
+                                       "%s must be a tuple",
+                                       "O", __reduce__);
                        goto finally;
                }
 
                size = PyTuple_Size(t);
 
-               if ((size != 3) && (size != 2)) {
-                       cPickle_ErrFormat(PicklingError, "tuple returned by %s must "
-                                         "contain only two or three elements", "O", __reduce__);
+               if (size != 3 && size != 2) {
+                       cPickle_ErrFormat(PicklingError, "tuple returned by "
+                               "%s must contain only two or three elements",
+                               "O", __reduce__);
                        goto finally;
                }
 
                callable = PyTuple_GET_ITEM(t, 0);
-
                arg_tup = PyTuple_GET_ITEM(t, 1);
 
                if (size > 2) {
@@ -2510,8 +2510,9 @@ save(Picklerobject *self, PyObject *args, int pers_save)
                }
 
                if (!( PyTuple_Check(arg_tup) || arg_tup==Py_None ))  {
-                       cPickle_ErrFormat(PicklingError, "Second element of tuple "
-                                         "returned by %s must be a tuple", "O", __reduce__);
+                       cPickle_ErrFormat(PicklingError, "Second element of "
+                               "tuple returned by %s must be a tuple",
+                               "O", __reduce__);
                        goto finally;
                }