[Python-checkins] CVS: python/dist/src/Lib inspect.py,1.14,1.15

Ka-Ping Yee ping@users.sourceforge.net
Fri, 13 Apr 2001 05:10:42 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv8563

Modified Files:
	inspect.py 
Log Message:
Robustify getfile() against classes that lie about their __module__s
    (such as the exceptions in _weakref and _locale!)


Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** inspect.py	2001/04/13 09:15:08	1.14
--- inspect.py	2001/04/13 12:10:40	1.15
***************
*** 174,178 ****
          raise TypeError, 'arg is a built-in module'
      if isclass(object):
!         object = sys.modules[object.__module__]
          if hasattr(object, '__file__'):
              return object.__file__
--- 174,178 ----
          raise TypeError, 'arg is a built-in module'
      if isclass(object):
!         object = sys.modules.get(object.__module__)
          if hasattr(object, '__file__'):
              return object.__file__