Skip to content

Commit 737fb89

Browse files
committed
Issue python#16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
1 parent 4001e96 commit 737fb89

36 files changed

+54
-54
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

Lib/asyncore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def recv(self, buffer_size):
393393
else:
394394
return data
395395
except socket.error as why:
396-
# winsock sometimes throws ENOTCONN
396+
# winsock sometimes raises ENOTCONN
397397
if why.args[0] in _DISCONNECTED:
398398
self.handle_close()
399399
return b''

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.
@@ -214,7 +214,7 @@ def _parsegen(self):
214214
# supposed to see in the body of the message.
215215
self._parse_headers(headers)
216216
# Headers-only parsing is a backwards compatibility hack, which was
217-
# necessary in the older parser, which could throw errors. All
217+
# necessary in the older parser, which could raise errors. All
218218
# remaining lines in the input are thrown into the message body.
219219
if self._headersonly:
220220
lines = []

Lib/email/header.py

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

Lib/importlib/_bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def get_code(self, fullname):
415415
source_mtime is not None):
416416
# If e.g. Jython ever implements imp.cache_from_source to have
417417
# their own cached file format, this block of code will most likely
418-
# throw an exception.
418+
# raise an exception.
419419
data = bytearray(imp.get_magic())
420420
data.extend(marshal._w_long(source_mtime))
421421
data.extend(marshal.dumps(code_object))

Lib/importlib/test/import_/test_fromlist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class HandlingFromlist(unittest.TestCase):
3939
4040
If a package is being imported, then what is listed in fromlist may be
4141
treated as a module to be imported [module]. But once again, even if
42-
something in fromlist does not exist as a module, no error is thrown
42+
something in fromlist does not exist as a module, no error is raised
4343
[no module]. And this extends to what is contained in __all__ when '*' is
4444
imported [using *]. And '*' does not need to be the only name in the
4545
fromlist [using * with others].

Lib/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
At the top of the I/O hierarchy is the abstract base class IOBase. It
55
defines the basic interface to a stream. Note, however, that there is no
66
separation between reading and writing to streams; implementations are
7-
allowed to throw an IOError if they do not support a given operation.
7+
allowed to raise an IOError if they do not support a given operation.
88
99
Extending IOBase is RawIOBase which deals simply with the reading and
1010
writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide

Lib/logging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False):
13551355
"""
13561356
sinfo = None
13571357
if _srcfile:
1358-
#IronPython doesn't track Python frames, so findCaller throws an
1358+
#IronPython doesn't track Python frames, so findCaller raises an
13591359
#exception on some versions of IronPython. We trap it here so that
13601360
#IronPython can use logging.
13611361
try:

Lib/multiprocessing/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def _exit_function(info=info, debug=debug, _run_finalizers=_run_finalizers,
301301
_run_finalizers(0)
302302
if current_process() is not None:
303303
# We check if the current process is None here because if
304-
# it's None, any call to ``active_children()`` will throw an
304+
# it's None, any call to ``active_children()`` will raise an
305305
# AttributeError (active_children winds up trying to get
306306
# attributes from util._current_process). This happens in a
307307
# variety of shutdown circumstances that are not well-understood

0 commit comments

Comments
 (0)