瀏覽代碼

Move moduledef to beginning of function.

MSVC doesn't seem to like mixing statements and definitions.
Jelmer Vernooij 8 年之前
父節點
當前提交
b3c2d6da2b
共有 1 個文件被更改,包括 12 次插入9 次删除
  1. 12 9
      dulwich/_pack.c

+ 12 - 9
dulwich/_pack.c

@@ -264,15 +264,6 @@ moduleinit(void)
 	PyObject *m;
 	PyObject *errors_module;
 
-	errors_module = PyImport_ImportModule("dulwich.errors");
-	if (errors_module == NULL)
-		return NULL;
-
-	PyExc_ApplyDeltaError = PyObject_GetAttrString(errors_module, "ApplyDeltaError");
-	Py_DECREF(errors_module);
-	if (PyExc_ApplyDeltaError == NULL)
-		return NULL;
-
 #if PY_MAJOR_VERSION >= 3
 	static struct PyModuleDef moduledef = {
 	  PyModuleDef_HEAD_INIT,
@@ -285,6 +276,18 @@ moduleinit(void)
 	  NULL,            /* m_clear*/
 	  NULL,            /* m_free */
 	};
+#endif
+
+	errors_module = PyImport_ImportModule("dulwich.errors");
+	if (errors_module == NULL)
+		return NULL;
+
+	PyExc_ApplyDeltaError = PyObject_GetAttrString(errors_module, "ApplyDeltaError");
+	Py_DECREF(errors_module);
+	if (PyExc_ApplyDeltaError == NULL)
+		return NULL;
+
+#if PY_MAJOR_VERSION >= 3
 	m = PyModule_Create(&moduledef);
 #else
 	m = Py_InitModule3("_pack", py_pack_methods, NULL);