]> granicus.if.org Git - python/commitdiff
Merged revisions 82068 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Fri, 18 Jun 2010 15:12:48 +0000 (15:12 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Fri, 18 Jun 2010 15:12:48 +0000 (15:12 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r82068 | senthil.kumaran | 2010-06-18 20:38:18 +0530 (Fri, 18 Jun 2010) | 3 lines

  Fix Issue1368368 - prompt_user_passwd() in FancyURLopener masks 401 Unauthorized error page
........

Lib/urllib/request.py
Misc/NEWS

index 95e8e3355775971e373ec6bf71d597d993a8e17c..e85b65c8b141d34b7a31d636a33440420cd1644c 100644 (file)
@@ -1870,7 +1870,8 @@ class FancyURLopener(URLopener):
         else:
             return self.http_error_default(url, fp, errcode, errmsg, headers)
 
-    def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
+    def http_error_401(self, url, fp, errcode, errmsg, headers, data=None,
+            retry=False):
         """Error 401 -- authentication required.
         This function supports Basic authentication only."""
         if not 'www-authenticate' in headers:
@@ -1886,13 +1887,17 @@ class FancyURLopener(URLopener):
         if scheme.lower() != 'basic':
             URLopener.http_error_default(self, url, fp,
                                          errcode, errmsg, headers)
+        if not retry:
+            URLopener.http_error_default(self, url, fp, errcode, errmsg,
+                    headers)
         name = 'retry_' + self.type + '_basic_auth'
         if data is None:
             return getattr(self,name)(url, realm)
         else:
             return getattr(self,name)(url, realm, data)
 
-    def http_error_407(self, url, fp, errcode, errmsg, headers, data=None):
+    def http_error_407(self, url, fp, errcode, errmsg, headers, data=None,
+            retry=False):
         """Error 407 -- proxy authentication required.
         This function supports Basic authentication only."""
         if not 'proxy-authenticate' in headers:
@@ -1908,6 +1913,9 @@ class FancyURLopener(URLopener):
         if scheme.lower() != 'basic':
             URLopener.http_error_default(self, url, fp,
                                          errcode, errmsg, headers)
+        if not retry:
+            URLopener.http_error_default(self, url, fp, errcode, errmsg,
+                    headers)
         name = 'retry_proxy_' + self.type + '_basic_auth'
         if data is None:
             return getattr(self,name)(url, realm)
index f8af2511dc30d161e92bdeef7b95798a2f53ee45..1f08e6e458894ddb282d008ed60889124b76aee2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -70,6 +70,10 @@ C-API
 Library
 -------
 
+- Issue #1368368: FancyURLOpener class changed to throw an Exception on wrong
+  password instead of presenting an interactive prompt. Older behavior can be
+  obtained by passing retry=True to http_error_xxx methods of FancyURLOpener.
+
 - Issue #8203: Fix IDLE Credits dialog: view_file() uses its encoding argument.
 
 - Issue #8720: fix regression caused by fix for #4050 by making getsourcefile