durin42 added a comment.
In https://phab.mercurial-scm.org/D5235#78172, @yuja wrote: > > +/* Convert a PyInt or PyLong to a long. Returns false if there is an > > + error, in which case an exception will already have been set. */ > > +static inline bool pylong_to_long(PyObject *pylong, long *out) > > Nit: I prefer 0/-1 return value instead of bool since that's the convention > of CPython API. I got lazy, but we can change it if we like. > > >> + *out = PyLong_AsLong(pylong); >> + return PyErr_Occurred() == NULL; > > Perhaps, checking `*out != -1` can be a fast path, though I don't know how > much we care about the performance here. I don't either, but it was easy to add the if statement. > > >> static int rustla_contains(rustlazyancestorsObject *self, PyObject *rev) >> { >> >> - if (!(PyInt_Check(rev))) { + long lrev; + if (!pylong_to_long(rev, &lrev)) { return 0; > > Needs `PyErr_Clear() since `non_int in self` isn't an error. Good catch, fixed. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5235 To: durin42, #hg-reviewers Cc: yuja, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel