D5224: revlog: check if PyInt_AS_LONG failed before using result
Yuya Nishihara
yuya at tcha.org
Tue Nov 6 07:37:42 EST 2018
> In this case, I suspect something really weird because `PyInt_AS_LONG()` doesn't exist on Python 3 and the docs for Python 2 say it performs no error checking. So the fact that it is setting an exception on Python 3 causes me to raise an eyebrow.
It's `#define PyLong_AS_LONG(op) PyLong_AsLong(op)`, sigh. And the reason
of the lack of `PyLong_AS_LONG(op)` would be that Python 3 has no bounded
integer type.
```
+ if (PyInt_Check(value)) {
+ long arg = PyInt_AS_LONG(value);
```
In this case, we'll probably have to replace `PyInt_Check() + PyInt_AS_LONG()`
with `PyInt_AsLong() + PyErr_Occurred()`.
More information about the Mercurial-devel
mailing list