[Python-checkins] r62463 - in python/trunk: Lib/test/test_urllib2.py Lib/urllib2.py Misc/NEWS
amaury.forgeotdarc
python-checkins at python.org
Tue Apr 22 23:14:41 CEST 2008
Author: amaury.forgeotdarc
Date: Tue Apr 22 23:14:41 2008
New Revision: 62463
Log:
Issue #2670: urllib2.build_opener() failed when two handlers
derive the same default base class.
Will backport.
Modified:
python/trunk/Lib/test/test_urllib2.py
python/trunk/Lib/urllib2.py
python/trunk/Misc/NEWS
Modified: python/trunk/Lib/test/test_urllib2.py
==============================================================================
--- python/trunk/Lib/test/test_urllib2.py (original)
+++ python/trunk/Lib/test/test_urllib2.py Tue Apr 22 23:14:41 2008
@@ -1063,6 +1063,12 @@
o = build_opener(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):
for h in opener.handlers:
if h.__class__ == handler_class:
Modified: python/trunk/Lib/urllib2.py
==============================================================================
--- python/trunk/Lib/urllib2.py (original)
+++ python/trunk/Lib/urllib2.py Tue Apr 22 23:14:41 2008
@@ -446,14 +446,14 @@
FTPHandler, FileHandler, HTTPErrorProcessor]
if hasattr(httplib, 'HTTPS'):
default_classes.append(HTTPSHandler)
- skip = []
+ skip = set()
for klass in default_classes:
for check in handlers:
if isclass(check):
if issubclass(check, klass):
- skip.append(klass)
+ skip.add(klass)
elif isinstance(check, klass):
- skip.append(klass)
+ skip.add(klass)
for klass in skip:
default_classes.remove(klass)
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Tue Apr 22 23:14:41 2008
@@ -18,6 +18,9 @@
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 phase(z) -> phi, polar(z) -> r, phi and rect(r, phi) -> z to the cmath
More information about the Python-checkins
mailing list