[Patches] [ python-Patches-1667860 ] urllib2 raises an UnboundLocalError if "auth-int" is the qop

SourceForge.net noreply at sourceforge.net
Sat Apr 14 23:27:19 CEST 2007


Patches item #1667860, was opened at 2007-02-24 15:19
Message generated for change (Comment added) made by varmaa
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1667860&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Atul Varma (varmaa)
Assigned to: Georg Brandl (gbrandl)
Summary: urllib2 raises an UnboundLocalError if "auth-int" is the qop

Initial Comment:
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.


----------------------------------------------------------------------

>Comment By: Atul Varma (varmaa)
Date: 2007-04-14 21:27

Message:
Logged In: YES 
user_id=863202
Originator: YES

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

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-13 08:08

Message:
Logged In: YES 
user_id=849994
Originator: NO

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

----------------------------------------------------------------------

Comment By: Atul Varma (varmaa)
Date: 2007-02-26 01:42

Message:
Logged In: YES 
user_id=863202
Originator: YES

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.


----------------------------------------------------------------------

Comment By: Atul Varma (varmaa)
Date: 2007-02-26 01:38

Message:
Logged In: YES 
user_id=863202
Originator: YES

File Added: test_urllib2_localnet.py

----------------------------------------------------------------------

Comment By: Atul Varma (varmaa)
Date: 2007-02-26 01:33

Message:
Logged In: YES 
user_id=863202
Originator: YES

File Added: urllib2_patch.diff

----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2007-02-25 17:37

Message:
Logged In: YES 
user_id=261020
Originator: NO

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.


----------------------------------------------------------------------

Comment By: Atul Varma (varmaa)
Date: 2007-02-24 15:20

Message:
Logged In: YES 
user_id=863202
Originator: YES

File Added: Urllib2ProxyTests.py

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1667860&group_id=5470


More information about the Patches mailing list