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
9686585a
Commit
9686585a
authored
Apr 22, 2008
by
Amaury Forgeot d'Arc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #2670: urllib2.build_opener() failed when two handlers
derive the same default base class. Will backport.
parent
d59fefb2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+6
-0
Lib/urllib2.py
Lib/urllib2.py
+3
-3
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib2.py
View file @
9686585a
...
@@ -1063,6 +1063,12 @@ class MiscTests(unittest.TestCase):
...
@@ -1063,6 +1063,12 @@ class MiscTests(unittest.TestCase):
o
=
build_opener
(
urllib2
.
HTTPHandler
())
o
=
build_opener
(
urllib2
.
HTTPHandler
())
self
.
opener_has_handler
(
o
,
urllib2
.
HTTPHandler
)
self
.
opener_has_handler
(
o
,
urllib2
.
HTTPHandler
)
# Issue2670: multiple handlers sharing the same base class
class
MyOtherHTTPHandler
(
urllib2
.
HTTPHandler
):
pass
o
=
build_opener
(
MyHTTPHandler
,
MyOtherHTTPHandler
)
self
.
opener_has_handler
(
o
,
MyHTTPHandler
)
self
.
opener_has_handler
(
o
,
MyOtherHTTPHandler
)
def
opener_has_handler
(
self
,
opener
,
handler_class
):
def
opener_has_handler
(
self
,
opener
,
handler_class
):
for
h
in
opener
.
handlers
:
for
h
in
opener
.
handlers
:
if
h
.
__class__
==
handler_class
:
if
h
.
__class__
==
handler_class
:
...
...
Lib/urllib2.py
View file @
9686585a
...
@@ -446,14 +446,14 @@ def build_opener(*handlers):
...
@@ -446,14 +446,14 @@ def build_opener(*handlers):
FTPHandler, FileHandler, HTTPErrorProcessor]
FTPHandler, FileHandler, HTTPErrorProcessor]
if hasattr(httplib, 'HTTPS'):
if hasattr(httplib, 'HTTPS'):
default_classes.append(HTTPSHandler)
default_classes.append(HTTPSHandler)
skip =
[]
skip =
set()
for klass in default_classes:
for klass in default_classes:
for check in handlers:
for check in handlers:
if isclass(check):
if isclass(check):
if issubclass(check, klass):
if issubclass(check, klass):
skip.a
ppen
d(klass)
skip.a
d
d(klass)
elif isinstance(check, klass):
elif isinstance(check, klass):
skip.a
ppen
d(klass)
skip.a
d
d(klass)
for klass in skip:
for klass in skip:
default_classes.remove(klass)
default_classes.remove(klass)
...
...
Misc/NEWS
View file @
9686585a
...
@@ -18,6 +18,9 @@ Core and builtins
...
@@ -18,6 +18,9 @@ Core and builtins
Extensions Modules
Extensions Modules
------------------
------------------
- Issue #2670: Fix a failure in urllib2.build_opener(), when passed two
handlers that derive the same default base class.
- Added kill, terminate and send_signal(sig) to subprocess.Popen.
- Added kill, terminate and send_signal(sig) to subprocess.Popen.
- Added phase(z) -> phi, polar(z) -> r, phi and rect(r, phi) -> z to the cmath
- Added phase(z) -> phi, polar(z) -> r, phi and rect(r, phi) -> z to the cmath
...
...
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