Hello Julien, Julien Cristau [2015-04-21 12:43 +0200]: > Thanks for the patch. I wonder if this package is still useful now that > the standard library's ssl module has been made usable in 2.7.9?
Ah, I didn't really check that TBH. I noticed it because python-urllib3 recommends it. Also, I attach an updated patch which cleans up the leaked test server process from debian/rules test. Older sbuilds apparently hang on those. Thanks, Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
* Run tests during package build: - Add python-openssl and openssl build dependencies. - debian/rules: Start test server and run test_urllib2.py. * Add fix_socket_close.diff: Fix AttributeError when destructing an un-opened Connection object. Exposed by test03_open_fails_unknown_loc. diff -u ndg-httpsclient-0.3.2/debian/control ndg-httpsclient-0.3.2/debian/control --- ndg-httpsclient-0.3.2/debian/control +++ ndg-httpsclient-0.3.2/debian/control @@ -5,7 +5,9 @@ Build-Depends: debhelper (>= 7), dh-python, + openssl, python-all, + python-openssl, python-setuptools, quilt, Standards-Version: 3.9.5 diff -u ndg-httpsclient-0.3.2/debian/patches/series ndg-httpsclient-0.3.2/debian/patches/series --- ndg-httpsclient-0.3.2/debian/patches/series +++ ndg-httpsclient-0.3.2/debian/patches/series @@ -1,0 +2 @@ +fix_socket_close.diff diff -u ndg-httpsclient-0.3.2/debian/rules ndg-httpsclient-0.3.2/debian/rules --- ndg-httpsclient-0.3.2/debian/rules +++ ndg-httpsclient-0.3.2/debian/rules @@ -4,0 +5,5 @@ + +override_dh_auto_test: + (cd ndg/httpsclient/test; scripts/openssl_https_server.sh) & S=$$! ; \ + trap "kill $$S; wait $$S" EXIT INT QUIT PIPE; \ + PYTHONPATH=. python ndg/httpsclient/test/test_urllib2.py only in patch2: unchanged: --- ndg-httpsclient-0.3.2.orig/debian/patches/fix_socket_close.diff +++ ndg-httpsclient-0.3.2/debian/patches/fix_socket_close.diff @@ -0,0 +1,45 @@ +Description: Fix AttributeError when destructing an un-opened Connection object + If we did not open the socket yet in connect(), and self.sock is still None, + don't try to close it in close(). + +Author: Martin Pitt <[email protected]> + +ERROR: test03_open_fails_unknown_loc (__main__.Urllib2TestCase) +---------------------------------------------------------------------- +Traceback (most recent call last): + File "ndg/httpsclient/test/test_urllib2.py", line 35, in test03_open_fails_unknown_loc + self.failUnlessRaises(URLError, opener.open, Constants.TEST_URI2) + File "/usr/lib/python2.7/unittest/case.py", line 612, in deprecated_func + return original_func(*args, **kwargs) + File "/usr/lib/python2.7/unittest/case.py", line 473, in assertRaises + callableObj(*args, **kwargs) + File "/usr/lib/python2.7/urllib2.py", line 431, in open + response = self._open(req, data) + File "/usr/lib/python2.7/urllib2.py", line 449, in _open + '_open', req) + File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain + result = func(*args) + File "/«PKGBUILDDIR»/ndg/httpsclient/https.py", line 121, in https_open + return self.do_open(customHTTPSContextConnection, req) + File "/usr/lib/python2.7/urllib2.py", line 1196, in do_open + h.close() + File "/«PKGBUILDDIR»/ndg/httpsclient/https.py", line 84, in close + self.sock.close() +AttributeError: 'NoneType' object has no attribute 'close' + + +Index: ndg-httpsclient-0.3.2/ndg/httpsclient/https.py +=================================================================== +--- ndg-httpsclient-0.3.2.orig/ndg/httpsclient/https.py ++++ ndg-httpsclient-0.3.2/ndg/httpsclient/https.py +@@ -81,7 +81,9 @@ class HTTPSConnection(HTTPConnection): + + def close(self): + """Close socket and shut down SSL connection""" +- self.sock.close() ++ if self.sock is not None: ++ self.sock.close() ++ self.sock = None + + + class HTTPSContextHandler(AbstractHTTPHandler):

