Author Oleg.Oleinik
Recipients Oleg.Oleinik
Date 2018-05-28.14:22:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1527517343.16.0.682650639539.issue33668@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-05-28 14:22:23Oleg.Oleiniksetrecipients: + Oleg.Oleinik
2018-05-28 14:22:23Oleg.Oleiniksetmessageid: <1527517343.16.0.682650639539.issue33668@psf.upfronthosting.co.za>
2018-05-28 14:22:23Oleg.Oleiniklinkissue33668 messages
2018-05-28 14:22:23Oleg.Oleinikcreate