Issue #7689: Allow pickling of dynamically created classes when their
metaclass is registered with copyreg.  Patch by Nicolas M. ThiƩry and
Craig Citro.
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 164d864..cb58349 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -3141,10 +3141,6 @@
         status = save_global(self, obj, NULL);
         goto done;
     }
-    else if (PyType_IsSubtype(type, &PyType_Type)) {
-        status = save_global(self, obj, NULL);
-        goto done;
-    }
 
     /* XXX: This part needs some unit tests. */
 
@@ -3163,6 +3159,10 @@
         Py_INCREF(obj);
         reduce_value = _Pickler_FastCall(self, reduce_func, obj);
     }
+    else if (PyType_IsSubtype(type, &PyType_Type)) {
+        status = save_global(self, obj, NULL);
+        goto done;
+    }
     else {
         static PyObject *reduce_str = NULL;
         static PyObject *reduce_ex_str = NULL;