New submission from Oleg Oleynik <[email protected]>:
I write file test.py:
def __getattr__(key):
return None
help(__name__)
when I try to run it I've got error:
Traceback (most recent call last):
File "test.py", line 5, in <module>
help(__name__)
File "C:\Program Files\Python37\lib\_sitebuiltins.py", line 103, in __call__
return pydoc.help(*args, **kwds)
File "C:\Program Files\Python37\lib\pydoc.py", line 1894, in __call__
self.help(request)
File "C:\Program Files\Python37\lib\pydoc.py", line 1944, in help
elif request: doc(request, 'Help on %s:', output=self._output)
File "C:\Program Files\Python37\lib\pydoc.py", line 1674, in doc
pager(render_doc(thing, title, forceload))
File "C:\Program Files\Python37\lib\pydoc.py", line 1667, in render_doc
return title % desc + '\n\n' + renderer.document(object, name)
File "C:\Program Files\Python37\lib\pydoc.py", line 385, in document
if inspect.ismodule(object): return self.docmodule(*args)
File "C:\Program Files\Python37\lib\pydoc.py", line 1136, in docmodule
for key, value in inspect.getmembers(object, inspect.isclass):
File "C:\Program Files\Python37\lib\inspect.py", line 330, in getmembers
for base in object.__bases__:
TypeError: 'NoneType' object is not iterable
If I change definition of __getattr__ function to:
def __getattr__(key):
raise AttributeError()
then help function runs without errors. But I need to return None value from
__getattr__ function.
When I wrote this function in class definition there is also no errors during
runtime
----------
components: Library (Lib)
messages: 317852
nosy: oleg_oleinik
priority: normal
severity: normal
status: open
title: Wrong behavior of help function on module
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33668>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com