homepage

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.

Author jaraco
Recipients docs@python, jaraco
Date 2011年10月18日.13:06:07
SpamBayes Score 1.8242996e-05
Marked as misclassified No
Message-id <1318943168.93.0.520705450261.issue13211@psf.upfronthosting.co.za>
In-reply-to
Content
The urllib2 docs indicate that HTTPError is a subclass of URLError and that URLError has an attribute of 'reason', but HTTPError does not have this attribute. The docs should be updated to reflect this deviance.
It appears the Python 3.2 docs no longer include documentation for URLError
Python 2.7.2
>>> try:urllib2.urlopen('http://api.wordnik.com/v4/word.json/foo/examples')
... except urllib2.HTTPError as exc:
... print(dir(exc))
...
['_HTTPError__super_init', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__getslice__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__unicode__', '__weakref__', 'args', 'close', 'code', 'errno', 'filename', 'fileno', 'fp', 'getcode', 'geturl', 'hdrs', 'headers', 'info', 'message', 'msg', 'next', 'read', 'readline', 'readlines', 'strerror', 'url']
The same issue exists in Python 3.2.2.
Here's what I propose:
 - For Python 3.2 and 3.3, update HTTPError to supply a @property, aliasing .msg (will .msg always be a suitable .reason?).
 - For Python 2.7, document the deviance, such as by adding the following wording to the HTTPError docs: "Unlike URLError, HTTPError does not supply a reason attribute. The reason can be retrieved through the msg attribute."
History
Date User Action Args
2011年10月18日 13:06:09jaracosetrecipients: + jaraco, docs@python
2011年10月18日 13:06:08jaracosetmessageid: <1318943168.93.0.520705450261.issue13211@psf.upfronthosting.co.za>
2011年10月18日 13:06:08jaracolinkissue13211 messages
2011年10月18日 13:06:07jaracocreate

AltStyle によって変換されたページ (->オリジナル) /