New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
urllib2 raises an UnboundLocalError if "auth-int" is the qop #44607
Comments
If a proxy server is connected to that specifies the "auth-int" quality of protection (qop) code--or any qop code aside from "auth", actually--urllib2 raises an UnboundLocalError exception. While this patch doesn't implement auth-int, it does modify the behavior of urllib2 such that it raises a URLError with the reason "qop '%s' is not supported', where %s is the name of the qop code. Two unit tests that test urllib2's functionality with an in-process proxy can be found at: http://varmaa.googlepages.com/Urllib2ProxyTests.py I will try to attach this file to this patch ticket if I can. I am also interested in integrating this unit testing suite with the Python standard lib unit tests, and am willing to work with you if this is desirable. One of the unit tests in this suite succeeds with the standard version of urllib2.py, but the other fails unless this patch is applied. This patch (and the unit test suite) applies to Python 2.4 and 2.5. |
File Added: Urllib2ProxyTests.py |
This looks useful. It would be nice to test failure cases too (e.g. wrong password, .add_password() not called, ...). I think if this goes into a new file (which might be reasonable), it should be named something like test_urllib2_localnet.py , to allow for adding more loopback tests, which will not always involve proxy handling. I suppose it should NOT depend on the network resource flag (Lib/test/regrtest.py -u network) since it's only localhost. Style (see PEP-8): Don't put whitespace inside brackets -- e.g. bad: fn( arg ) good: fn(arg) Use this_kind_of_name or thiskind if short, not thisKind. Imports and classes etc. don't need comments to label them as such. Probably is useful to label the BaseHTTPServer code though (maybe '# Local proxy test infrastructure'). See e.g. end of Lib/test/test_urllib2net.py for appropriate stdlib test boilerplate. Your patch has inconsistent line endings, BTW. |
File Added: urllib2_patch.diff |
File Added: test_urllib2_localnet.py |
Thanks for the feedback, John--I've applied your suggestions to the testing suite (including renaming the file name) and the patch file. The only thing I haven't done yet is add tests for failure cases, but I wanted to submit the "refactored" version of the test suite before doing that so I know I'm on the right track. |
The new test file looks good, so if you complete the patch I'll apply it. |
Sorry for the delay; I've added two failure cases to the testing suite--one which supplies bad password information and another that has no password information to supply--so the patch should now be complete. Please let me know if you need anything else. File Added: test_urllib2_localnet.py |
I get this error with the newest test file: test_urllib2_localnet
Traceback (most recent call last):
File "/home/gbr/devel/python/Lib/SocketServer.py", line 222, in handle_request
self.process_request(request, client_address)
File "/home/gbr/devel/python/Lib/SocketServer.py", line 241, in process_request
self.finish_request(request, client_address)
File "/home/gbr/devel/python/Lib/SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/home/gbr/devel/python/Lib/SocketServer.py", line 523, in __init__
self.handle()
File "/home/gbr/devel/python/Lib/BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "/home/gbr/devel/python/Lib/BaseHTTPServer.py", line 310, in handle_one_request
method()
File "/home/gbr/devel/python/Lib/test/test_urllib2_localnet.py", line 220, in do_GET
self.wfile.write("Our apologies, but our server is down due to "
File "/home/gbr/devel/python/Lib/socket.py", line 263, in write
self.flush()
File "/home/gbr/devel/python/Lib/socket.py", line 250, in flush
self._sock.sendall(buffer)
error: (32, 'Broken pipe')
test test_urllib2_localnet produced unexpected output:
**********************************************************************
*** lines 2-4 of actual output doesn't appear in expected output after line 1:
+ + Exception happened during processing of request from ('127.0.0.1', 33141) 1 test failed: |
Ack, sorry about that Georg--I'll investigate and fix this over the weekend. |
Okay, the broken pipe bug should be fixed now--let me know if there are any other problems, or if the broken pipe bug persists. |
Okay, accepted as rev. 55805, 55806 (2.5). Thanks for your continuous efforts! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: