Submitter | Yuya Nishihara |
---|---|
Date | April 9, 2019, 10:42 p.m. |
Message ID | <1792bd9807b6ff434df2.1554849747@mimosa> |
Download | mbox | patch |
Permalink | /patch/39550/ |
State | Accepted |
Headers | show |
Comments
On Wed, Apr 10, 2019 at 1:47 AM Yuya Nishihara <yuya@tcha.org> wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1554814777 -32400 > # Tue Apr 09 21:59:37 2019 +0900 > # Node ID 1792bd9807b6ff434df207e33b94d2ea32555b3e > # Parent 864f9f63d3ed371ab3d283911790d4f990926499 > cext: cast s# arguments of Py_BuildValue() to Py_ssize_t > > The doc doesn't state that "s#" of Py_BuildValue() is controlled by > PY_SSIZE_T_CLEAN (unlike the one for PyArg_ParseTuple()), but actually > it's switched to Py_ssize_t. > > https://docs.python.org/2/c-api/arg.html#c.Py_BuildValue > https://github.com/python/cpython/blob/2.7/Python/modsupport.c#L432 > > Follow up for b01bbb8ff1f2 and 896b19d12c08. > Queued this, many thanks!
Patch
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -184,7 +184,8 @@ static PyObject *parse_dirstate(PyObject goto quit; } - parents = Py_BuildValue(PY23("s#s#", "y#y#"), str, 20, str + 20, 20); + parents = Py_BuildValue(PY23("s#s#", "y#y#"), str, (Py_ssize_t)20, + str + 20, (Py_ssize_t)20); if (!parents) { goto quit; } diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -366,7 +366,7 @@ static PyObject *index_get(indexObject * entry = Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2, c_node_id, - 20); + (Py_ssize_t)20); if (entry) { PyObject_GC_UnTrack(entry); @@ -3017,8 +3017,9 @@ void revlog_module_init(PyObject *mod) PyModule_AddObject(mod, "nodetree", (PyObject *)&nodetreeType); if (!nullentry) { - nullentry = Py_BuildValue(PY23("iiiiiiis#", "iiiiiiiy#"), 0, 0, - 0, -1, -1, -1, -1, nullid, 20); + nullentry = + Py_BuildValue(PY23("iiiiiiis#", "iiiiiiiy#"), 0, 0, 0, -1, + -1, -1, -1, nullid, (Py_ssize_t)20); } if (nullentry) PyObject_GC_UnTrack(nullentry);