Julien Cristau reported and provided the fix [1]. I added an assertion.
Note Python documentation (2.7 to 3.5) says "L" in Py_BuildValue might be
unsupported on some platforms:
L (int) [PY_LONG_LONG] Convert a Python integer to a C long long. This format is only available on platforms that support long long (or _int64 on Windows).
But it is required to build Python 2.7 itself [2]. So using it won't affect
supported platforms.
[1]: https://bz.mercurial-scm.org/show_bug.cgi?id=5885#c3
[2]: https://bugs.python.org/issue27961