[Python-checkins] python/dist/src/Objects abstract.c,2.110,2.111 classobject.c,2.164,2.165

Guido van Rossum guido@python.org
Thu, 12 Dec 2002 11:47:43 -0500


> Modified Files:
> 	abstract.c classobject.c 
> Log Message:
> Enhance issubclass() and PyObject_IsSubclass() so that a tuple is
> supported as the second argument. This has the same meaning as
> for isinstance(), i.e. issubclass(X, (A, B)) is equivalent
> to issubclass(X, A) or issubclass(X, B). Compared to isinstance(),
> this patch does not search the tuple recursively for classes, i.e.
> any entry in the tuple that is not a class, will result in a
> TypeError.

Why the latter limitation?  Now we have an inconsistency:

  >>> isinstance(1, (long,(float,int)))
  True
  >>> issubclass(int, (long,(float,int)))
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
  TypeError: issubclass() arg 2 must be a class or tuple of classes
  >>> 

--Guido van Rossum (home page: http://www.python.org/~guido/)