pydoc.py has typo.
file: C:\Python25\Lib\pydoc.py
method: locate
quote:
def locate(path, forceload=0):
"""Locate an object by name or dotted path, importing as necessary."""
parts = [part for part in split(path, '.') if part]
module, n = None, 0
while n < len(parts):
nextmodule = safeimport(join(parts[:n+1], '.'), forceload)
if nextmodule: module, n = nextmodule, n + 1
else: break
if module:
object = module
for part in parts[n:]:
try: object = getattr(object, part)
except AttributeError: return None
return object
else:
if hasattr(__builtin__, path):
return getattr(__builtin__, path)
bug:
I believe that by '__builtin__' you meant '__builtins__' in the last two lines.
if hasattr(__builtin__, path):
return getattr(__builtin__, path)
should read:
if hasattr(__builtins__, path):
return getattr(__builtins__, path)
>>> sys.platform
'win32'
>>> sys.version
'2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]'
Thanks, Charles
|