bottlenose icon indicating copy to clipboard operation
bottlenose copied to clipboard

help() causes TypeError

Open JoshRosen opened this issue 13 years ago • 3 comments

When I call help(amazon) I get the following error

Python 2.7.2 |EPD 7.1-2 (32-bit)| (default, Jul 27 2011, 13:29:32) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> amazon = bottlenose.Amazon(AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
>>> help(amazon)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site.py", line 467, in __call__
    return pydoc.help(*args, **kwds)
  File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/pydoc.py", line 1727, in __call__
    self.help(request)
  File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/pydoc.py", line 1771, in help
    else: doc(request, 'Help on %s:')
  File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/pydoc.py", line 1511, in doc
    pager(render_doc(thing, title, forceload))
  File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/pydoc.py", line 1488, in render_doc
    if name and '.' in name:
TypeError: argument of type 'AmazonCall' is not iterable

The problem is that AmazonCall.__getattr__ interprets Amazon.__name__ as an Amazon API call instead of raising AttributeError. Pydoc calls __name__ expecting to receive either a string or AttributeError, which leads to the error in the traceback. Perhaps double-underscore methods should be exempt from the special __getattr__ handling.

JoshRosen avatar Jan 25 '12 21:01 JoshRosen

Hi, is this still relevant or has it been resolved?

stephnr avatar Apr 08 '14 23:04 stephnr

Any updates on this issue?

stephnr avatar Sep 10 '14 20:09 stephnr

Does this still happen on today's Python 2.7.15 and Python 3.7.1?

cclauss avatar Dec 03 '18 17:12 cclauss