Message317852
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 |
|
Date |
User |
Action |
Args |
2018-05-28 14:22:23 | Oleg.Oleinik | set | recipients:
+ Oleg.Oleinik |
2018-05-28 14:22:23 | Oleg.Oleinik | set | messageid: <1527517343.16.0.682650639539.issue33668@psf.upfronthosting.co.za> |
2018-05-28 14:22:23 | Oleg.Oleinik | link | issue33668 messages |
2018-05-28 14:22:23 | Oleg.Oleinik | create | |
|