summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2017-03-16 14:26:45 +0100
committerJelmer Vernooij <jelmer@jelmer.uk>2017-03-16 16:00:40 +0000
commit40ab981fb7937d5a2d02a139e905833605ab4762 (patch)
treee77bb5fc14ef26b430847b690e3c14b1b6d31d7b
parent85b04f76db7cc14e1b9d890aeab1d884a18bbbd5 (diff)
Replace PyString_AsString with PyString_AS_STRING
Fix issue #509: Replace PyString_AsString with PyString_AS_STRING to workaround a PyPy bug in cpyext (PyPy older than 5.6).
-rw-r--r--dulwich/_diff_tree.c1
-rw-r--r--dulwich/_pack.c6
2 files changed, 3 insertions, 4 deletions
diff --git a/dulwich/_diff_tree.c b/dulwich/_diff_tree.c
index 149dccd8..2ea5ced7 100644
--- a/dulwich/_diff_tree.c
+++ b/dulwich/_diff_tree.c
@@ -38,7 +38,6 @@ typedef int Py_ssize_t;
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AS_LONG PyLong_AS_LONG
#define PyString_AS_STRING PyBytes_AS_STRING
-#define PyString_AsString PyBytes_AsString
#define PyString_AsStringAndSize PyBytes_AsStringAndSize
#define PyString_Check PyBytes_Check
#define PyString_CheckExact PyBytes_CheckExact
diff --git a/dulwich/_pack.c b/dulwich/_pack.c
index ddac9e70..e3ae9182 100644
--- a/dulwich/_pack.c
+++ b/dulwich/_pack.c
@@ -24,7 +24,7 @@
#if PY_MAJOR_VERSION >= 3
#define PyInt_FromLong PyLong_FromLong
#define PyString_AS_STRING PyBytes_AS_STRING
-#define PyString_AsString PyBytes_AsString
+#define PyString_AS_STRING PyBytes_AS_STRING
#define PyString_Check PyBytes_Check
#define PyString_CheckExact PyBytes_CheckExact
#define PyString_FromStringAndSize PyBytes_FromStringAndSize
@@ -133,7 +133,7 @@ static PyObject *py_apply_delta(PyObject *self, PyObject *args)
Py_DECREF(py_delta);
return NULL;
}
- out = (uint8_t *)PyString_AsString(ret);
+ out = (uint8_t *)PyString_AS_STRING(ret);
while (index < delta_len) {
uint8_t cmd = delta[index];
index++;
@@ -238,7 +238,7 @@ static PyObject *py_bisect_find_sha(PyObject *self, PyObject *args)
Py_DECREF(file_sha);
return NULL;
}
- cmp = memcmp(PyString_AsString(file_sha), sha, 20);
+ cmp = memcmp(PyString_AS_STRING(file_sha), sha, 20);
Py_DECREF(file_sha);
if (cmp < 0)
start = i + 1;