D7878: sha1dc: use proper string functions on Python 2/3
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Wed Jan 15 01:54:51 UTC 2020
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
PyString_FromStringAndSize doesn't exist on Python 3: we need
to use PyUnicode_FromStringAndSize.
The extension now compiles without warnings on Python 2 and 3.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D7878
AFFECTED FILES
mercurial/thirdparty/sha1dc/cext.c
CHANGE DETAILS
diff --git a/mercurial/thirdparty/sha1dc/cext.c b/mercurial/thirdparty/sha1dc/cext.c
--- a/mercurial/thirdparty/sha1dc/cext.c
+++ b/mercurial/thirdparty/sha1dc/cext.c
@@ -95,7 +95,7 @@
hexhash[i * 2] = hexdigit[hash[i] >> 4];
hexhash[i * 2 + 1] = hexdigit[hash[i] & 15];
}
- return PyString_FromStringAndSize(hexhash, 40);
+ return PY23(PyString_FromStringAndSize, PyUnicode_FromStringAndSize)(hexhash, 40);
}
static PyTypeObject sha1ctxType;
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list