Skip to content

Commit a191959

Browse files
committed
Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2 parents f61dc4c + 5b89840 commit a191959

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+64
-64
lines changed

Doc/howto/cporting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ behave slightly differently from real Capsules. Specifically:
253253

254254
* :c:func:`PyCapsule_GetName` always returns NULL.
255255

256-
* :c:func:`PyCapsule_SetName` always throws an exception and
256+
* :c:func:`PyCapsule_SetName` always raises an exception and
257257
returns failure. (Since there's no way to store a name
258258
in a CObject, noisy failure of :c:func:`PyCapsule_SetName`
259259
was deemed preferable to silent failure here. If this is

Doc/library/contextlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Functions and classes provided:
184184
files = [stack.enter_context(open(fname)) for fname in filenames]
185185
# All opened files will automatically be closed at the end of
186186
# the with statement, even if attempts to open files later
187-
# in the list throw an exception
187+
# in the list raise an exception
188188

189189
Each instance maintains a stack of registered callbacks that are called in
190190
reverse order when the instance is closed (either explicitly or implicitly

Doc/library/imaplib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ There's also a subclass for secure connections:
7575
:class:`ssl.SSLContext` object which allows bundling SSL configuration
7676
options, certificates and private keys into a single (potentially long-lived)
7777
structure. Note that the *keyfile*/*certfile* parameters are mutually exclusive with *ssl_context*,
78-
a :class:`ValueError` is thrown if *keyfile*/*certfile* is provided along with *ssl_context*.
78+
a :class:`ValueError` is raised if *keyfile*/*certfile* is provided along with *ssl_context*.
7979

8080
.. versionchanged:: 3.3
8181
*ssl_context* parameter added.

Doc/library/os.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ Querying the size of a terminal
11711171
output) specifies which file descriptor should be queried.
11721172

11731173
If the file descriptor is not connected to a terminal, an :exc:`OSError`
1174-
is thrown.
1174+
is raised.
11751175

11761176
:func:`shutil.get_terminal_size` is the high-level function which
11771177
should normally be used, ``os.get_terminal_size`` is the low-level
@@ -1945,7 +1945,7 @@ features:
19451945
:mod:`os` module permit use of their *dir_fd* parameter. Different platforms
19461946
provide different functionality, and an option that might work on one might
19471947
be unsupported on another. For consistency's sakes, functions that support
1948-
*dir_fd* always allow specifying the parameter, but will throw an exception
1948+
*dir_fd* always allow specifying the parameter, but will raise an exception
19491949
if the functionality is not actually available.
19501950

19511951
To check whether a particular function permits use of its *dir_fd*
@@ -1986,7 +1986,7 @@ features:
19861986
descriptor. Different platforms provide different functionality, and an
19871987
option that might work on one might be unsupported on another. For
19881988
consistency's sakes, functions that support *fd* always allow specifying
1989-
the parameter, but will throw an exception if the functionality is not
1989+
the parameter, but will raise an exception if the functionality is not
19901990
actually available.
19911991

19921992
To check whether a particular function permits specifying an open file
@@ -2007,7 +2007,7 @@ features:
20072007
platforms provide different functionality, and an option that might work on
20082008
one might be unsupported on another. For consistency's sakes, functions that
20092009
support *follow_symlinks* always allow specifying the parameter, but will
2010-
throw an exception if the functionality is not actually available.
2010+
raise an exception if the functionality is not actually available.
20112011

20122012
To check whether a particular function permits use of its *follow_symlinks*
20132013
parameter, use the ``in`` operator on ``supports_follow_symlinks``. As an

Lib/asyncore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def recv(self, buffer_size):
385385
else:
386386
return data
387387
except socket.error as why:
388-
# winsock sometimes throws ENOTCONN
388+
# winsock sometimes raises ENOTCONN
389389
if why.args[0] in _DISCONNECTED:
390390
self.handle_close()
391391
return b''

Lib/contextlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class ExitStack(object):
151151
files = [stack.enter_context(open(fname)) for fname in filenames]
152152
# All opened files will automatically be closed at the end of
153153
# the with statement, even if attempts to open files later
154-
# in the list throw an exception
154+
# in the list raise an exception
155155
156156
"""
157157
def __init__(self):

Lib/distutils/tests/test_msvc9compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class msvc9compilerTestCase(support.TempdirManager,
104104
unittest.TestCase):
105105

106106
def test_no_compiler(self):
107-
# makes sure query_vcvarsall throws
107+
# makes sure query_vcvarsall raises
108108
# a DistutilsPlatformError if the compiler
109109
# is not found
110110
from distutils.msvc9compiler import query_vcvarsall

Lib/email/feedparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
data. When you have no more data to push into the parser, call .close().
1414
This completes the parsing and returns the root message object.
1515
16-
The other advantage of this parser is that it will never throw a parsing
16+
The other advantage of this parser is that it will never raise a parsing
1717
exception. Instead, when it finds something unexpected, it adds a 'defect' to
1818
the current message. Defects are just instances that live on the message
1919
object's .defects attribute.
@@ -228,7 +228,7 @@ def _parsegen(self):
228228
# supposed to see in the body of the message.
229229
self._parse_headers(headers)
230230
# Headers-only parsing is a backwards compatibility hack, which was
231-
# necessary in the older parser, which could throw errors. All
231+
# necessary in the older parser, which could raise errors. All
232232
# remaining lines in the input are thrown into the message body.
233233
if self._headersonly:
234234
lines = []

Lib/email/header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def append(self, s, charset=None, errors='strict'):
298298
else:
299299
s = s.decode(input_charset, errors)
300300
# Ensure that the bytes we're storing can be decoded to the output
301-
# character set, otherwise an early error is thrown.
301+
# character set, otherwise an early error is raised.
302302
output_charset = charset.output_codec or 'us-ascii'
303303
if output_charset != _charset.UNKNOWN8BIT:
304304
try:

Lib/email/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def formataddr(pair, charset='utf-8'):
8383
'utf-8'.
8484
"""
8585
name, address = pair
86-
# The address MUST (per RFC) be ascii, so throw a UnicodeError if it isn't.
86+
# The address MUST (per RFC) be ascii, so raise an UnicodeError if it isn't.
8787
address.encode('ascii')
8888
if name:
8989
try:

0 commit comments

Comments
 (0)