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: pydoc.py has typo.
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: charlesmchen, georg.brandl
Priority: normal Keywords:

Created on 2007-04-23 16:09 by charlesmchen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg31870 - (view) Author: charlesmchen (charlesmchen) Date: 2007-04-23 16:09
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
msg31871 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-04-24 15:11
I don't think so. __builtin__ is imported at the top of the module, and its use is intentional here.
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44886
2007-04-23 16:09:26charlesmchencreate