summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-30 05:09:37 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-30 05:09:37 (GMT)
commitd38b1c74f3f28a3f9a73c142d9be83425adaa6e1 (patch)
treed3b062c6eaa6d7e6c5be8cfdaeb71d7470563a68 /Objects/longobject.c
parentac1af8093ef39028c993c5b343c557d94528fd25 (diff)
downloadcpython-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.c8
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;
}