Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
49df9215
Commit
49df9215
authored
Apr 22, 2015
by
Facundo Batista
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23887: urllib.error.HTTPError now has a proper repr() representation.
parent
09248713
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
44 deletions
+111
-44
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+102
-43
Lib/urllib/error.py
Lib/urllib/error.py
+6
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib2.py
View file @
49df9215
This diff is collapsed.
Click to expand it.
Lib/urllib/error.py
View file @
49df9215
...
...
@@ -35,6 +35,7 @@ class URLError(OSError):
def
__str__
(
self
):
return
'<urlopen error %s>'
%
self
.
reason
class
HTTPError
(
URLError
,
urllib
.
response
.
addinfourl
):
"""Raised when HTTP error occurs, but also acts like non-error return"""
__super_init
=
urllib
.
response
.
addinfourl
.
__init__
...
...
@@ -55,6 +56,9 @@ class HTTPError(URLError, urllib.response.addinfourl):
def
__str__
(
self
):
return
'HTTP Error %s: %s'
%
(
self
.
code
,
self
.
msg
)
def
__repr__
(
self
):
return
'<HTTPError %s: %r>'
%
(
self
.
code
,
self
.
msg
)
# since URLError specifies a .reason attribute, HTTPError should also
# provide this attribute. See issue13211 for discussion.
@
property
...
...
@@ -69,8 +73,9 @@ class HTTPError(URLError, urllib.response.addinfourl):
def
headers
(
self
,
headers
):
self
.
hdrs
=
headers
# exception raised when downloaded size does not match content-length
class
ContentTooShortError
(
URLError
):
"""Exception raised when downloaded size does not match content-length."""
def
__init__
(
self
,
message
,
content
):
URLError
.
__init__
(
self
,
message
)
self
.
content
=
content
Misc/NEWS
View file @
49df9215
...
...
@@ -33,6 +33,9 @@ Library
-
Issue
#
23728
:
binascii
.
crc_hqx
()
could
return
an
integer
outside
of
the
range
0
-
0xffff
for
empty
data
.
-
Issue
#
23887
:
urllib
.
error
.
HTTPError
now
has
a
proper
repr
()
representation
.
Patch
by
Berker
Peksag
.
What
's New in Python 3.5.0 alpha 4?
===================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment