Skip to content
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

Closed
varmaa mannequin opened this issue Feb 24, 2007 · 12 comments
Closed

urllib2 raises an UnboundLocalError if "auth-int" is the qop #44607

varmaa mannequin opened this issue Feb 24, 2007 · 12 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@varmaa
Copy link
Mannequin

varmaa mannequin commented Feb 24, 2007

BPO 1667860
Nosy @birkenfeld
Files
  • urllib2_patch.diff: Patch to fix the UnboundLocalError bug, w/ consistent line endings and PEP 8 conformance
  • test_urllib2_localnet.py: stdlib testing suite for urllib2 using loopback http proxy w/ tests for qop types "auth" and "auth-int"
  • test_urllib2_localnet.py: stdlib testing suite for urllib2 using loopback http proxy w/ tests for qop types "auth" and "auth-int" and failure cases
  • test_urllib2_localnet.py: stdlib testing suite for urllib2 using loopback http proxy, fixes broken pipe errors
  • 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:

    assignee = 'https://github.com/birkenfeld'
    closed_at = <Date 2007-06-07.13:35:05.000>
    created_at = <Date 2007-02-24.15:19:04.000>
    labels = ['library']
    title = 'urllib2 raises an UnboundLocalError if "auth-int" is the qop'
    updated_at = <Date 2007-06-07.13:35:05.000>
    user = 'https://bugs.python.org/varmaa'

    bugs.python.org fields:

    activity = <Date 2007-06-07.13:35:05.000>
    actor = 'georg.brandl'
    assignee = 'georg.brandl'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2007-02-24.15:19:04.000>
    creator = 'varmaa'
    dependencies = []
    files = ['7786', '7787', '7788', '7789']
    hgrepos = []
    issue_num = 1667860
    keywords = ['patch']
    message_count = 12.0
    messages = ['51940', '51941', '51942', '51943', '51944', '51945', '51946', '51947', '51948', '51949', '51950', '51951']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'jjlee', 'varmaa']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1667860'
    versions = ['Python 2.5']

    @varmaa
    Copy link
    Mannequin Author

    varmaa mannequin commented Feb 24, 2007

    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.

    @varmaa varmaa mannequin closed this as completed Feb 24, 2007
    @varmaa varmaa mannequin closed this as completed Feb 24, 2007
    @varmaa varmaa mannequin assigned birkenfeld Feb 24, 2007
    @varmaa varmaa mannequin added stdlib Python modules in the Lib dir labels Feb 24, 2007
    @varmaa
    Copy link
    Mannequin Author

    varmaa mannequin commented Feb 24, 2007

    File Added: Urllib2ProxyTests.py

    @jjlee
    Copy link
    Mannequin

    jjlee mannequin commented Feb 25, 2007

    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.

    @varmaa
    Copy link
    Mannequin Author

    varmaa mannequin commented Feb 26, 2007

    File Added: urllib2_patch.diff

    @varmaa
    Copy link
    Mannequin Author

    varmaa mannequin commented Feb 26, 2007

    File Added: test_urllib2_localnet.py

    @varmaa
    Copy link
    Mannequin Author

    varmaa mannequin commented Feb 26, 2007

    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.

    @birkenfeld
    Copy link
    Member

    The new test file looks good, so if you complete the patch I'll apply it.

    @varmaa
    Copy link
    Mannequin Author

    varmaa mannequin commented Apr 14, 2007

    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

    @birkenfeld
    Copy link
    Member

    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:
    test_urllib2_localnet

    @varmaa
    Copy link
    Mannequin Author

    varmaa mannequin commented May 11, 2007

    Ack, sorry about that Georg--I'll investigate and fix this over the weekend.

    @varmaa
    Copy link
    Mannequin Author

    varmaa mannequin commented Jun 2, 2007

    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.
    File Added: test_urllib2_localnet.py

    @birkenfeld
    Copy link
    Member

    Okay, accepted as rev. 55805, 55806 (2.5).

    Thanks for your continuous efforts!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant