2
0
Эх сурвалжийг харах

Fix compatibility with Python 3.8.

Jelmer Vernooij 5 жил өмнө
parent
commit
8f73bc51e2

+ 4 - 5
.travis.yml

@@ -27,15 +27,14 @@ matrix:
       env: TEST_REQUIRE=fastimport
       dist: xenial
       sudo: true
+    - python: 3.8
+      env: TEST_REQUIRE=fastimport
+      dist: xenial
+      sudo: true
     - python: 3.6
       env: PURE=true
     - python: 2.7
       env: PURE=true
-    # flakes checker fails on python 3.8-dev:
-    #- python: 3.8-dev
-    #  env: TEST_REQUIRE=fastimport
-    #  dist: xenial
-    #  sudo: true
 
 install:
   - travis_retry pip install -U pip coverage codecov flake8 $TEST_REQUIRE

+ 3 - 0
NEWS

@@ -21,6 +21,9 @@
  * Fix regression that added a dependency on C git for the
    test suite. (Jelmer Vernooij, #720)
 
+ * Fix compatibility with Python 3.8 - mostly deprecation warnings.
+   (Jelmer Vernooij)
+
 0.19.12	2019-08-13
 
  BUG FIXES

+ 1 - 0
dulwich/_diff_tree.c

@@ -18,6 +18,7 @@
  * License, Version 2.0.
  */
 
+#define PY_SSIZE_T_CLEAN
 #include <Python.h>
 #include <sys/stat.h>
 

+ 2 - 1
dulwich/_objects.c

@@ -18,6 +18,7 @@
  * License, Version 2.0.
  */
 
+#define PY_SSIZE_T_CLEAN
 #include <Python.h>
 #include <stdlib.h>
 #include <sys/stat.h>
@@ -61,7 +62,7 @@ static PyObject *sha_to_pyhex(const unsigned char *sha)
 static PyObject *py_parse_tree(PyObject *self, PyObject *args, PyObject *kw)
 {
 	char *text, *start, *end;
-	int len, strict;
+	Py_ssize_t len; int strict;
 	size_t namelen;
 	PyObject *ret, *item, *name, *sha, *py_strict = NULL;
 	static char *kwlist[] = {"text", "strict", NULL};

+ 3 - 2
dulwich/_pack.c

@@ -18,6 +18,7 @@
  * License, Version 2.0.
  */
 
+#define PY_SSIZE_T_CLEAN
 #include <Python.h>
 #include <stdint.h>
 
@@ -205,7 +206,7 @@ static PyObject *py_bisect_find_sha(PyObject *self, PyObject *args)
 {
 	PyObject *unpack_name;
 	char *sha;
-	int sha_len;
+	Py_ssize_t sha_len;
 	int start, end;
 #if PY_MAJOR_VERSION >= 3
 	if (!PyArg_ParseTuple(args, "iiy#O", &start, &end,
@@ -227,7 +228,7 @@ static PyObject *py_bisect_find_sha(PyObject *self, PyObject *args)
 
 	while (start <= end) {
 		PyObject *file_sha;
-		int i = (start + end)/2;
+		Py_ssize_t i = (start + end)/2;
 		int cmp;
 		file_sha = PyObject_CallFunction(unpack_name, "i", i);
 		if (file_sha == NULL) {

+ 2 - 2
dulwich/tests/compat/test_patch.py

@@ -100,7 +100,7 @@ class CompatPatchTestCase(CompatTestCase):
         new_files = set(os.listdir(copy_path))
 
         # Check that we have the exact same files in both repositories
-        self.assertEquals(original_files, new_files)
+        self.assertEqual(original_files, new_files)
 
         for file in original_files:
             if file == ".git":
@@ -117,4 +117,4 @@ class CompatPatchTestCase(CompatTestCase):
             with open(copy_file_path, "rb") as copy_file:
                 copy_content = copy_file.read()
 
-            self.assertEquals(original_content, copy_content)
+            self.assertEqual(original_content, copy_content)