Bug 669847 - urllib2's AbstractBasicAuthHandler is limited to 6 requests
urllib2's AbstractBasicAuthHandler is limited to 6 requests
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: python (Show other bugs)
6.1
Unspecified Unspecified
low Severity medium
: rc
: ---
Assigned To: Dave Malcolm
Petr Šplíchal
: Regression
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-14 19:30 EST by Dave Malcolm
Modified: 2016-05-31 21:47 EDT (History)
3 users (show)

See Also:
Fixed In Version: python-2.6.6-8.el6
Doc Type: Bug Fix
Doc Text:
Basic HTTP authentication via the urllib2 module was limited to six requests because the "retried" attribute was not reset when authentication was successful. This attribute is now reset, and authentication requests work as expected.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-05-19 07:37:11 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Dave Malcolm 2011-01-14 19:30:25 EST
Description of problem:
See e.g. http://permalink.gmane.org/gmane.comp.python.enthought.devel/27376

This appears to be a regression in python 2.6.6 relative to 2.6.5

Upstream bug report:
  http://bugs.python.org/issue9639

It is fixed in the upstream 2.7 branch, but was not backported to 2.6 as it's not a security fix:
  http://svn.python.org/view?view=rev&revision=84207


Version-Release number of selected component (if applicable):
  python-2.6.6-3.el6.x86_64

How reproducible:
  100%


Steps to Reproduce:
  Run the following python code fragment, from the enthought mailing list (which relies on browserspy.dk):

---- BEGIN QUOTE ----
import urllib2

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, 'http://browserspy.dk', 'test', 'test')
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)

for i in xrange(10):
    print "Loop {0}".format(i)
    pagehandle = opener.open('http://browserspy.dk/password-ok.php')
    pagehandle.close()
---- END QUOTE -----


Actual results:
  With 2.6.6, it fails on i == 6 with this output:

---- BEGIN QUOTE ----
Loop 0
Loop 1
Loop 2
Loop 3
Loop 4
Loop 5
Loop 6
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/lib64/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.6/urllib2.py", line 429, in error
    result = self._call_chain(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 864, in http_error_401
    url, req, headers)
  File "/usr/lib64/python2.6/urllib2.py", line 833, in http_error_auth_reqed
    headers, None)
urllib2.HTTPError: HTTP Error 401: basic auth failed
---- END QUOTE -----


Expected results:
With python-2.6.5-9.fc14.x86_64, it successfully runs 10 iterations:
---- BEGIN QUOTE ----
Loop 0
Loop 1
Loop 2
Loop 3
Loop 4
Loop 5
Loop 6
Loop 7
Loop 8
Loop 9
---- END QUOTE -----


(See also bug 649274)
Comment 8 Laura Bailey 2011-05-09 23:11:55 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Basic HTTP authentication via the urllib2 module was limited to six requests because the "retried" attribute was not reset when authentication was successful. This attribute is now reset, and authentication requests work as expected.
Comment 9 errata-xmlrpc 2011-05-19 07:37:11 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0554.html
Comment 10 errata-xmlrpc 2011-05-19 09:07:47 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0554.html

Note You need to log in before you can comment on or make changes to this bug.