[PATCH 3 of 6 V2] rust: exposing in parsers module

Georges Racinet gracinet at anybox.fr
Fri Oct 12 05:33:51 EDT 2018


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).



-- 
Georges Racinet
Anybox SAS, http://anybox.fr
Téléphone: +33 6 51 32 07 27
GPG: B59E 22AB B842 CAED 77F7 7A7F C34F A519 33AB 0A35, sur serveurs publics

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20181012/635eb651/attachment.html>


More information about the Mercurial-devel mailing list