]> granicus.if.org Git - python/commitdiff
fix alleged refleak
authorBenjamin Peterson <benjamin@python.org>
Thu, 24 Dec 2009 01:09:53 +0000 (01:09 +0000)
committerBenjamin Peterson <benjamin@python.org>
Thu, 24 Dec 2009 01:09:53 +0000 (01:09 +0000)
Lib/test/test_urllib2.py

index 01c214a252dc4cd1674ab1fe94f709b2948a3905..1c57ec656390d07e35d56db863176aeb6c163f1b 100644 (file)
@@ -292,10 +292,11 @@ class MockHTTPClass:
             self._tunnel_headers = headers
         else:
             self._tunnel_headers.clear()
-    def request(self, method, url, body=None, headers={}):
+    def request(self, method, url, body=None, headers=None):
         self.method = method
         self.selector = url
-        self.req_headers += headers.items()
+        if headers is not None:
+            self.req_headers += headers.items()
         self.req_headers.sort()
         if body:
             self.data = body
@@ -415,7 +416,11 @@ class MockHTTPHandler(urllib2.BaseHandler):
 class MockHTTPSHandler(urllib2.AbstractHTTPHandler):
     # Useful for testing the Proxy-Authorization request by verifying the
     # properties of httpcon
-    httpconn = MockHTTPClass()
+
+    def __init__(self):
+        urllib2.AbstractHTTPHandler.__init__(self)
+        self.httpconn = MockHTTPClass()
+
     def https_open(self, req):
         return self.do_open(self.httpconn, req)