[issue16714] Raise exceptions, don't throw

Serhiy Storchaka report at bugs.python.org
Wed Dec 19 17:17:59 CET 2012


Serhiy Storchaka added the comment:

I found one error. In Lib/email/header.py for 2.7 'raise' should be
reverted to 'throw'.

Also I miss a past form. Second patch replaces 'threw' with 'raised'.

----------
Added file: http://bugs.python.org/file28360/throw_away.patch
Added file: http://bugs.python.org/file28361/throw2raised.patch
Added file: http://bugs.python.org/file28362/throw2raised-3.2.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16714>
_______________________________________
-------------- next part --------------
diff -r 8c2635afbfe1 Lib/email/header.py
--- a/Lib/email/header.py	Tue Dec 18 21:27:37 2012 +0200
+++ b/Lib/email/header.py	Wed Dec 19 18:00:22 2012 +0200
@@ -103,7 +103,7 @@
                         dec = email.base64mime.decode(encoded)
                     except binascii.Error:
                         # Turn this into a higher level exception.  BAW: Right
-                        # now we raise the lower level exception away but
+                        # now we throw the lower level exception away but
                         # when/if we get exception chaining, we'll preserve it.
                         raise HeaderParseError
                 if dec is None:
-------------- next part --------------
diff -r bb94f6222fef Lib/pkgutil.py
--- a/Lib/pkgutil.py	Wed Dec 19 14:33:35 2012 +0200
+++ b/Lib/pkgutil.py	Wed Dec 19 18:11:03 2012 +0200
@@ -503,7 +503,7 @@
     except (ImportError, AttributeError, TypeError, ValueError) as ex:
         # This hack fixes an impedance mismatch between pkgutil and
         # importlib, where the latter raises other errors for cases where
-        # pkgutil previously threw ImportError
+        # pkgutil previously raised ImportError
         msg = "Error while finding loader for {!r} ({}: {})"
         raise ImportError(msg.format(fullname, type(ex), ex)) from ex
 
diff -r bb94f6222fef Lib/test/test_urllib2.py
--- a/Lib/test/test_urllib2.py	Wed Dec 19 14:33:35 2012 +0200
+++ b/Lib/test/test_urllib2.py	Wed Dec 19 18:11:03 2012 +0200
@@ -1302,7 +1302,7 @@
                               )
 
     def test_basic_and_digest_auth_handlers(self):
-        # HTTPDigestAuthHandler threw an exception if it couldn't handle a 40*
+        # HTTPDigestAuthHandler raised an exception if it couldn't handle a 40*
         # response (http://python.org/sf/1479302), where it should instead
         # return None to allow another handler (especially
         # HTTPBasicAuthHandler) to handle the response.
diff -r bb94f6222fef Lib/test/test_winreg.py
--- a/Lib/test/test_winreg.py	Wed Dec 19 14:33:35 2012 +0200
+++ b/Lib/test/test_winreg.py	Wed Dec 19 18:11:03 2012 +0200
@@ -277,7 +277,7 @@
 
     def test_long_key(self):
         # Issue2810, in 2.6 and 3.1 when the key name was exactly 256
-        # characters, EnumKey threw "WindowsError: More data is
+        # characters, EnumKey raised "WindowsError: More data is
         # available"
         name = 'x'*256
         try:
-------------- next part --------------
diff -r cf62fbf2171a Lib/test/test_urllib2.py
--- a/Lib/test/test_urllib2.py	Fri Nov 02 07:34:37 2012 +0100
+++ b/Lib/test/test_urllib2.py	Wed Dec 19 18:15:49 2012 +0200
@@ -1252,7 +1252,7 @@
                               )
 
     def test_basic_and_digest_auth_handlers(self):
-        # HTTPDigestAuthHandler threw an exception if it couldn't handle a 40*
+        # HTTPDigestAuthHandler raised an exception if it couldn't handle a 40*
         # response (http://python.org/sf/1479302), where it should instead
         # return None to allow another handler (especially
         # HTTPBasicAuthHandler) to handle the response.
diff -r cf62fbf2171a Lib/test/test_winreg.py
--- a/Lib/test/test_winreg.py	Fri Nov 02 07:34:37 2012 +0100
+++ b/Lib/test/test_winreg.py	Wed Dec 19 18:15:49 2012 +0200
@@ -277,7 +277,7 @@
 
     def test_long_key(self):
         # Issue2810, in 2.6 and 3.1 when the key name was exactly 256
-        # characters, EnumKey threw "WindowsError: More data is
+        # characters, EnumKey raised "WindowsError: More data is
         # available"
         name = 'x'*256
         try:


More information about the Python-bugs-list mailing list