]> granicus.if.org Git - python/commitdiff
merge from 3.2
authorSenthil Kumaran <senthil@uthcode.com>
Sun, 23 Dec 2012 17:12:13 +0000 (09:12 -0800)
committerSenthil Kumaran <senthil@uthcode.com>
Sun, 23 Dec 2012 17:12:13 +0000 (09:12 -0800)
Fix Issue15701 - HTTPError info method call raises AttributeError. Fix that to return headers correctly

1  2 
Lib/test/test_urllib2.py
Lib/urllib/error.py
Misc/NEWS

index 2d94ba449f3b4d894b6a2853980e24c3edd8c5ff,5eab30af76553cd00a1e7dffa4a21ba681a2feac..ccd5419b709e00aafff8230614bac9fb8f96712e
@@@ -1495,18 -1438,32 +1495,34 @@@ class RequestTests(unittest.TestCase)
          req = Request(url)
          self.assertEqual(req.get_full_url(), url)
  
- def test_HTTPError_interface():
-     """
-     Issue 13211 reveals that HTTPError didn't implement the URLError
-     interface even though HTTPError is a subclass of URLError.
-     >>> msg = 'something bad happened'
-     >>> url = code = hdrs = fp = None
-     >>> err = urllib.error.HTTPError(url, code, msg, hdrs, fp)
-     >>> assert hasattr(err, 'reason')
-     >>> err.reason
-     'something bad happened'
-     """
+     def test_HTTPError_interface(self):
+         """
+         Issue 13211 reveals that HTTPError didn't implement the URLError
+         interface even though HTTPError is a subclass of URLError.
 -        >>> err = urllib.error.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None)
++        >>> msg = 'something bad happened'
++        >>> url = code = hdrs = fp = None
++        >>> err = urllib.error.HTTPError(url, code, msg, hdrs, fp)
+         >>> assert hasattr(err, 'reason')
+         >>> err.reason
+         'something bad happened'
+         """
+     def test_HTTPError_interface_call(self):
+         """
+         Issue 15701 - HTTPError interface has info method available from URLError
+         """
+         err = urllib.request.HTTPError(msg="something bad happened", url=None,
+                                 code=None, hdrs='Content-Length:42', fp=None)
+         self.assertTrue(hasattr(err, 'reason'))
+         assert hasattr(err, 'reason')
+         assert hasattr(err, 'info')
+         assert callable(err.info)
+         try:
+             err.info()
+         except AttributeError:
+             self.fail('err.info call failed.')
+         self.assertEqual(err.info(), "Content-Length:42")
  
  def test_main(verbose=None):
      from test import test_urllib2
Simple merge
diff --cc Misc/NEWS
index 97e24fa1db9c9b1e7ba5f601ea1eb20e10be5cca,9a33632c7fdd4ef3a5adb6c5acdac26d978a9285..31b33561818897db9ce2bd641bff6a13b3829334
+++ b/Misc/NEWS
@@@ -114,8 -179,8 +114,10 @@@ Core and Builtin
  Library
  -------
  
+ - Issue #15701: Fix HTTPError info method call to return the headers information.
 +- Issue #16752: Add a missing import to modulefinder. Patch by Berker Peksag.
 +
  - Issue #16646: ftplib.FTP.makeport() might lose socket error details.
    (patch by Serhiy Storchaka)