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.

Author hdima
Recipients hdima
Date 2009-04-12.18:29:09
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1239560953.4.0.0140518593947.issue5742@psf.upfronthosting.co.za>
In-reply-to
Content
Currently help(zlib) gives the following traceback:

Python 3.1a2+ (py3k:71538M, Apr 12 2009, 21:54:44) 
>>> import zlib
>>> help(zlib)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Lib/site.py", line 429, in __call__
    return pydoc.help(*args, **kwds)
  File "Lib/pydoc.py", line 1709, in __call__
    self.help(request)
  File "Lib/pydoc.py", line 1755, in help
    else: doc(request, 'Help on %s:')
  File "Lib/pydoc.py", line 1505, in doc
    pager(render_doc(thing, title, forceload))
  File "Lib/pydoc.py", line 1500, in render_doc
    return title % desc + '\n\n' + text.document(object, name)
  File "Lib/pydoc.py", line 320, in document
    if inspect.ismodule(object): return self.docmodule(*args)
  File "Lib/pydoc.py", line 1086, in docmodule
    contents.append(self.document(value, key, name))
  File "Lib/pydoc.py", line 321, in document
    if inspect.isclass(object): return self.docclass(*args)
  File "Lib/pydoc.py", line 1131, in docclass
    doc = getdoc(object)
  File "Lib/pydoc.py", line 81, in getdoc
    result = inspect.getdoc(object) or inspect.getcomments(object)
  File "Lib/inspect.py", line 581, in getcomments
    lines, lnum = findsource(object)
  File "Lib/inspect.py", line 524, in findsource
    lines = linecache.getlines(file, module.__dict__)
  File "Lib/linecache.py", line 41, in getlines
    return updatecache(filename, module_globals)
  File "Lib/linecache.py", line 127, in updatecache
    lines = fp.readlines()
  File "Lib/codecs.py", line 300, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 41-42:
invalid data

After some investigation I've found that inspect.findsource() try to use
getfile() if getsourcefile() fail to find the source file. I don't see
why findsource() should return lines from a compiled file so I think
it's a bug. The same bug also exists in Python 2.7 although it's not so
critical. I've attached the patch which fixes the problem.
History
Date User Action Args
2009-04-12 18:29:13hdimasetrecipients: + hdima
2009-04-12 18:29:13hdimasetmessageid: <1239560953.4.0.0140518593947.issue5742@psf.upfronthosting.co.za>
2009-04-12 18:29:11hdimalinkissue5742 messages
2009-04-12 18:29:10hdimacreate