This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: inspect.isclass() fails with custom __getattr__
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, jkloth
Priority: normal Keywords:

Created on 2005-06-21 20:20 by jkloth, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg60765 - (view) Author: Jeremy Kloth (jkloth) * Date: 2005-06-21 20:20
inspect.isclass() can return True for instances of classes   
which define a __getattr__ method.  For example:   
   
>>> class Namespace(unicode):   
...    def __getattr__(self, attr):   
...       return '<%s>' % (self + attr)   
...   
>>> inspect.isclass(Namespace('foo'))   
True   
   
Changing inspect.isclass() to:   
  return isinstance(object, (types.ClassType, type))   
solves this issue.   
   
The check for __bases__ is no longer need due to   
type/class unification.   
msg80054 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-01-17 22:28
Finally fixed in r68676.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42107
2009-01-17 22:28:08benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg80054
nosy: + benjamin.peterson
2005-06-21 20:20:01jklothcreate