Raised when HTTP error occurs, but also acts like non-error return
| 33 | |
| 34 | |
| 35 | class HTTPError(URLError, urllib.response.addinfourl): |
| 36 | """Raised when HTTP error occurs, but also acts like non-error return""" |
| 37 | __super_init = urllib.response.addinfourl.__init__ |
| 38 | |
| 39 | def __init__(self, url, code, msg, hdrs, fp): |
| 40 | self.code = code |
| 41 | self.msg = msg |
| 42 | self.hdrs = hdrs |
| 43 | self.fp = fp |
| 44 | self.filename = url |
| 45 | if fp is None: |
| 46 | fp = io.BytesIO() |
| 47 | self.__super_init(fp, hdrs, url, code) |
| 48 | |
| 49 | def __str__(self): |
| 50 | return 'HTTP Error %s: %s' % (self.code, self.msg) |
| 51 | |
| 52 | def __repr__(self): |
| 53 | return '<HTTPError %s: %r>' % (self.code, self.msg) |
| 54 | |
| 55 | # since URLError specifies a .reason attribute, HTTPError should also |
| 56 | # provide this attribute. See issue13211 for discussion. |
| 57 | @property |
| 58 | def reason(self): |
| 59 | return self.msg |
| 60 | |
| 61 | @property |
| 62 | def headers(self): |
| 63 | return self.hdrs |
| 64 | |
| 65 | @headers.setter |
| 66 | def headers(self, headers): |
| 67 | self.hdrs = headers |
| 68 | |
| 69 | |
| 70 | class ContentTooShortError(URLError): |
no outgoing calls
no test coverage detected
searching dependent graphs…