[PATCH 3 of 6 V2] rust: exposing in parsers module
Yuya Nishihara
yuya at tcha.org
Fri Oct 12 06:16:56 EDT 2018
On Fri, 12 Oct 2018 11:33:51 +0200, Georges Racinet wrote:
> On 10/12/2018 07:05 AM, Yuya Nishihara wrote:
> >> +
> >> + if (initrevs == NULL) {
> >> + PyErr_NoMemory();
> >> + goto bail;
> >> + }
> >> +
> >> + for (i=0; i<linit; i++) {
> >> + initrevs[i] = PyInt_AsLong(PyList_GET_ITEM(initrevsarg, i));
> > PyInt_AsLong() may fail if a list item isn't an integer.
> >
> In our particular case, since the convention for failure is that
> PyInt_AsLong returns -1, that's equivalent to adding the null revision,
> which is filterered right away on the Rust side.
>
> Reference: https://docs.python.org/2/c-api/int.html#c.PyInt_AsLong
>
> It's a bit of coincidental programming, but I think a simple comment is
> less dangerous than writing more C to shorten initrevs from there (not
> sure that code will live for long anyway).
Yes, but I think reporting the error is better than silently ignoring it.
if (PyErr_Occurred())
goto bail;
More information about the Mercurial-devel
mailing list