bltinmodule.c: added round(x, [n]); coerce() of two class instances

will try to coerce anyway.
classobject.c: instance 'nonzero' should first try __nonzero__
only then __len__.
This commit is contained in:
Guido van Rossum 1993-02-12 16:29:05 +00:00
parent e8a3c28f8d
commit 9e51f9bec8
2 changed files with 32 additions and 3 deletions

View file

@ -619,9 +619,9 @@ instance_nonzero(self)
object *func, *res;
long outcome;
if ((func = instance_getattr(self, "__len__")) == NULL) {
if ((func = instance_getattr(self, "__nonzero__")) == NULL) {
err_clear();
if ((func = instance_getattr(self, "__nonzero__")) == NULL) {
if ((func = instance_getattr(self, "__len__")) == NULL) {
err_clear();
/* Fall back to the default behavior:
all instances are nonzero */