# HG changeset patch # User Gregory Szorc # Date 2020-01-15 01:53:43 # Node ID 29a110e2776e0e47dd4d6a7c994e614b4f9fee58 # Parent c3f741bb2f33cd0c6a8f42ee80e75d36c236dad0 sha1dc: use proper string functions on Python 2/3 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. Differential Revision: https://phab.mercurial-scm.org/D7878 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 @@ static PyObject *pysha1ctx_hexdigest(pys 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;