D5224: revlog: check if PyInt_AS_LONG failed before using result

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Tue Nov 6 07:38:54 EST 2018


yuja added a comment.


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

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5224

To: durin42, #hg-reviewers, indygreg
Cc: yuja, indygreg, mercurial-devel


More information about the Mercurial-devel mailing list