Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 237:16f467717d7a legacy-trunk
Declare ticker as int; made testbool generic for all numeric types
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 14 May 1991 11:51:49 +0000 |
| parents | e71b6fec86e5 |
| children | 26b2eed78381 |
line wrap: on
line diff
--- a/Python/ceval.c Sun May 05 20:16:20 1991 +0000 +++ b/Python/ceval.c Tue May 14 11:51:49 1991 +0000 @@ -162,7 +162,7 @@ lineno = -1; for (;;) { - static ticker; + static int ticker; /* Do periodic things */ @@ -983,16 +983,14 @@ 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; }
