diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-09-30 05:09:37 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-09-30 05:09:37 (GMT) |
commit | d38b1c74f3f28a3f9a73c142d9be83425adaa6e1 (patch) | |
tree | d3b062c6eaa6d7e6c5be8cfdaeb71d7470563a68 /Objects/longobject.c | |
parent | ac1af8093ef39028c993c5b343c557d94528fd25 (diff) | |
download | cpython-d38b1c74f3f28a3f9a73c142d9be83425adaa6e1.zip cpython-d38b1c74f3f28a3f9a73c142d9be83425adaa6e1.tar.gz cpython-d38b1c74f3f28a3f9a73c142d9be83425adaa6e1.tar.bz2 |
SF [#466125] PyLong_AsLongLong works for any integer.
Generalize PyLong_AsLongLong to accept int arguments too. The real point
is so that PyArg_ParseTuple's 'L' code does too. That code was
undocumented (AFAICT), so documented it.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 8f7d9e4..be4af3f 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -679,7 +679,13 @@ PyLong_AsLongLong(PyObject *vv) int one = 1; int res; - if (vv == NULL || !PyLong_Check(vv)) { + if (vv == NULL) { + PyErr_BadInternalCall(); + return -1; + } + if (!PyLong_Check(vv)) { + if (PyInt_Check(vv)) + return (LONG_LONG)PyInt_AsLong(vv); PyErr_BadInternalCall(); return -1; } |