summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-02-18 16:36:28 (GMT)
committerGuido van Rossum <guido@python.org>2003-02-18 16:36:28 (GMT)
commit6921eca227ac2283ebcdf98e10aebea57bd5daf3 (patch)
treee705276019bc84a0d827dc0aa31b8dc1c2d4dcff /Objects
parent55dc26cbc764574bf1cca7e74bb511d623e1af7d (diff)
downloadcpython-6921eca227ac2283ebcdf98e10aebea57bd5daf3.zip
cpython-6921eca227ac2283ebcdf98e10aebea57bd5daf3.tar.gz
cpython-6921eca227ac2283ebcdf98e10aebea57bd5daf3.tar.bz2
Make PyNumber_Check() a bit more careful, since all sorts of things
now have tp_as_number. Check for nb_int or nb_float.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index c18d5e7..b4fbd32 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -308,7 +308,9 @@ int PyObject_AsWriteBuffer(PyObject *obj,
int
PyNumber_Check(PyObject *o)
{
- return o && o->ob_type->tp_as_number;
+ return o && o->ob_type->tp_as_number &&
+ (o->ob_type->tp_as_number->nb_int ||
+ o->ob_type->tp_as_number->nb_float);
}
/* Binary operators */