Browse Source

py3k: These need to return a value since in Py3k they're no longer void

Python 2.x shouldn't care about it though the signature is void there.

As exhibited in error:

dulwich/_diff_tree.c:449:2: error: non-void function 'init_diff_tree'
should return a value [-Wreturn-type]
Hannu Valtonen 10 years ago
parent
commit
3d2e49ae41
2 changed files with 44 additions and 12 deletions
  1. 8 0
      dulwich/_diff_tree.c
  2. 36 12
      dulwich/_objects.c

+ 8 - 0
dulwich/_diff_tree.c

@@ -437,7 +437,11 @@ init_diff_tree(void)
 	}
 
 	Py_DECREF(diff_tree_mod);
+#if PY_MAJOR_VERSION < 3
 	return;
+#else
+	return NULL;
+#endif
 
 error:
 	Py_XDECREF(objects_mod);
@@ -446,5 +450,9 @@ error:
 	Py_XDECREF(block_size_obj);
 	Py_XDECREF(defaultdict_cls);
 	Py_XDECREF(int_cls);
+#if PY_MAJOR_VERSION < 3
 	return;
+#else
+	return NULL;
+#endif
 }

+ 36 - 12
dulwich/_objects.c

@@ -104,7 +104,7 @@ static PyObject *py_parse_tree(PyObject *self, PyObject *args, PyObject *kw)
 			Py_DECREF(name);
 			return NULL;
 		}
-		item = Py_BuildValue("(NlN)", name, mode, sha); 
+		item = Py_BuildValue("(NlN)", name, mode, sha);
 		if (item == NULL) {
 			Py_DECREF(ret);
 			Py_DECREF(sha);
@@ -254,28 +254,52 @@ init_objects(void)
 	PyObject *m, *objects_mod, *errors_mod;
 
 	m = Py_InitModule3("_objects", py_objects_methods, NULL);
-	if (m == NULL)
-		return;
-
+	if (m == NULL) {
+#if PY_MAJOR_VERSION < 3
+	  return;
+#else
+	  return NULL;
+#endif
+	}
 
 	errors_mod = PyImport_ImportModule("dulwich.errors");
-	if (errors_mod == NULL)
-		return;
+	if (errors_mod == NULL) {
+#if PY_MAJOR_VERSION < 3
+	  return;
+#else
+	  return NULL;
+#endif
+	}
 
 	object_format_exception_cls = PyObject_GetAttrString(
 		errors_mod, "ObjectFormatException");
 	Py_DECREF(errors_mod);
-	if (object_format_exception_cls == NULL)
-		return;
+	if (object_format_exception_cls == NULL) {
+#if PY_MAJOR_VERSION < 3
+	  return;
+#else
+	  return NULL;
+#endif
+	}
 
 	/* This is a circular import but should be safe since this module is
 	 * imported at at the very bottom of objects.py. */
 	objects_mod = PyImport_ImportModule("dulwich.objects");
-	if (objects_mod == NULL)
-		return;
+	if (objects_mod == NULL) {
+#if PY_MAJOR_VERSION < 3
+	  return;
+#else
+	  return NULL;
+#endif
+	}
 
 	tree_entry_cls = PyObject_GetAttrString(objects_mod, "TreeEntry");
 	Py_DECREF(objects_mod);
-	if (tree_entry_cls == NULL)
-		return;
+	if (tree_entry_cls == NULL) {
+#if PY_MAJOR_VERSION < 3
+	  return;
+#else
+	  return NULL;
+#endif
+	}
 }