summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-05-14 11:51:49 (GMT)
committerGuido van Rossum <guido@python.org>1991-05-14 11:51:49 (GMT)
commit4965bc8ac4c9922f87ec7bfa839a85c95f411a5c (patch)
tree9fbdbbab6e51974c62e5b09f827b86595b8dc655 /Python/ceval.c
parentf023c463d77c8321dcea935a7225562411f97bd1 (diff)
downloadcpython-4965bc8ac4c9922f87ec7bfa839a85c95f411a5c.zip
cpython-4965bc8ac4c9922f87ec7bfa839a85c95f411a5c.tar.gz
cpython-4965bc8ac4c9922f87ec7bfa839a85c95f411a5c.tar.bz2
Declare ticker as int; made testbool generic for all numeric types
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 99570e9..82410d5 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -162,7 +162,7 @@ eval_code(co, globals, locals, arg)
lineno = -1;
for (;;) {
- static ticker;
+ static int ticker;
/* Do periodic things */
@@ -983,16 +983,14 @@ static int
testbool(v)
object *v;
{
- if (is_intobject(v))
- return getintvalue(v) != 0;
- if (is_floatobject(v))
- return getfloatvalue(v) != 0.0;
+ if (v == None)
+ return 0;
+ if (v->ob_type->tp_as_number != NULL)
+ return (*v->ob_type->tp_as_number->nb_nonzero)(v);
if (v->ob_type->tp_as_sequence != NULL)
return (*v->ob_type->tp_as_sequence->sq_length)(v) != 0;
if (v->ob_type->tp_as_mapping != NULL)
return (*v->ob_type->tp_as_mapping->mp_length)(v) != 0;
- if (v == None)
- return 0;
/* All other objects are 'true' */
return 1;
}