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.
Created on 2009年04月12日 18:29 by hdima, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| inspect.patch | hdima, 2009年04月12日 18:29 | Patch for Lib/inspect.py | ||
| Messages (2) | |||
|---|---|---|---|
| msg85916 - (view) | Author: Dmitry Vasiliev (hdima) | Date: 2009年04月12日 18:29 | |
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. |
|||
| msg86550 - (view) | Author: Daniel Diniz (ajaksu2) * (Python triager) | Date: 2009年04月25日 20:51 | |
This is a duplicate of issue 4050. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:47 | admin | set | github: 49992 |
| 2009年04月25日 20:51:20 | ajaksu2 | set | status: open -> closed nosy: + ajaksu2 messages: + msg86550 superseder: inspect.findsource() returns binary data for shared library modules resolution: duplicate |
| 2009年04月14日 02:51:16 | ajaksu2 | set | priority: normal type: crash -> behavior stage: test needed |
| 2009年04月12日 18:29:11 | hdima | create | |