Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
737fb89d
Commit
737fb89d
authored
Dec 18, 2012
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
parent
4001e961
Changes
36
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
54 additions
and
54 deletions
+54
-54
Doc/howto/cporting.rst
Doc/howto/cporting.rst
+1
-1
Lib/asyncore.py
Lib/asyncore.py
+1
-1
Lib/distutils/tests/test_msvc9compiler.py
Lib/distutils/tests/test_msvc9compiler.py
+1
-1
Lib/email/feedparser.py
Lib/email/feedparser.py
+2
-2
Lib/email/header.py
Lib/email/header.py
+1
-1
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+1
-1
Lib/importlib/test/import_/test_fromlist.py
Lib/importlib/test/import_/test_fromlist.py
+1
-1
Lib/io.py
Lib/io.py
+1
-1
Lib/logging/__init__.py
Lib/logging/__init__.py
+1
-1
Lib/multiprocessing/util.py
Lib/multiprocessing/util.py
+1
-1
Lib/runpy.py
Lib/runpy.py
+1
-1
Lib/tempfile.py
Lib/tempfile.py
+1
-1
Lib/test/test_codeop.py
Lib/test/test_codeop.py
+1
-1
Lib/test/test_docxmlrpc.py
Lib/test/test_docxmlrpc.py
+1
-1
Lib/test/test_imaplib.py
Lib/test/test_imaplib.py
+1
-1
Lib/test/test_minidom.py
Lib/test/test_minidom.py
+1
-1
Lib/test/test_os.py
Lib/test/test_os.py
+8
-8
Lib/test/test_pty.py
Lib/test/test_pty.py
+1
-1
Lib/test/test_sax.py
Lib/test/test_sax.py
+2
-2
Lib/test/test_signal.py
Lib/test/test_signal.py
+2
-2
Lib/test/test_socketserver.py
Lib/test/test_socketserver.py
+1
-1
Lib/test/test_sys_settrace.py
Lib/test/test_sys_settrace.py
+1
-1
Lib/test/test_time.py
Lib/test/test_time.py
+1
-1
Lib/test/test_uu.py
Lib/test/test_uu.py
+2
-2
Lib/test/test_winreg.py
Lib/test/test_winreg.py
+2
-2
Lib/test/test_zipfile.py
Lib/test/test_zipfile.py
+1
-1
Lib/tkinter/__init__.py
Lib/tkinter/__init__.py
+1
-1
Lib/unittest/case.py
Lib/unittest/case.py
+2
-2
Lib/wsgiref/validate.py
Lib/wsgiref/validate.py
+2
-2
Lib/xml/sax/_exceptions.py
Lib/xml/sax/_exceptions.py
+3
-3
Lib/xml/sax/xmlreader.py
Lib/xml/sax/xmlreader.py
+1
-1
Lib/xmlrpc/client.py
Lib/xmlrpc/client.py
+1
-1
Modules/_io/_iomodule.c
Modules/_io/_iomodule.c
+1
-1
Modules/parsermodule.c
Modules/parsermodule.c
+3
-3
Modules/posixmodule.c
Modules/posixmodule.c
+1
-1
Tools/scripts/serve.py
Tools/scripts/serve.py
+1
-1
No files found.
Doc/howto/cporting.rst
View file @
737fb89d
...
@@ -253,7 +253,7 @@ behave slightly differently from real Capsules. Specifically:
...
@@ -253,7 +253,7 @@ behave slightly differently from real Capsules. Specifically:
* :c:func:`PyCapsule_GetName` always returns NULL.
* :c:func:`PyCapsule_GetName` always returns NULL.
* :c:func:`PyCapsule_SetName` always
throw
s an exception and
* :c:func:`PyCapsule_SetName` always
raise
s an exception and
returns failure. (Since there's no way to store a name
returns failure. (Since there's no way to store a name
in a CObject, noisy failure of :c:func:`PyCapsule_SetName`
in a CObject, noisy failure of :c:func:`PyCapsule_SetName`
was deemed preferable to silent failure here. If this is
was deemed preferable to silent failure here. If this is
...
...
Lib/asyncore.py
View file @
737fb89d
...
@@ -393,7 +393,7 @@ class dispatcher:
...
@@ -393,7 +393,7 @@ class dispatcher:
else
:
else
:
return
data
return
data
except
socket
.
error
as
why
:
except
socket
.
error
as
why
:
# winsock sometimes
throw
s ENOTCONN
# winsock sometimes
raise
s ENOTCONN
if
why
.
args
[
0
]
in
_DISCONNECTED
:
if
why
.
args
[
0
]
in
_DISCONNECTED
:
self
.
handle_close
()
self
.
handle_close
()
return
b''
return
b''
...
...
Lib/distutils/tests/test_msvc9compiler.py
View file @
737fb89d
...
@@ -104,7 +104,7 @@ class msvc9compilerTestCase(support.TempdirManager,
...
@@ -104,7 +104,7 @@ class msvc9compilerTestCase(support.TempdirManager,
unittest
.
TestCase
):
unittest
.
TestCase
):
def
test_no_compiler
(
self
):
def
test_no_compiler
(
self
):
# makes sure query_vcvarsall
throw
s
# makes sure query_vcvarsall
raise
s
# a DistutilsPlatformError if the compiler
# a DistutilsPlatformError if the compiler
# is not found
# is not found
from
distutils.msvc9compiler
import
query_vcvarsall
from
distutils.msvc9compiler
import
query_vcvarsall
...
...
Lib/email/feedparser.py
View file @
737fb89d
...
@@ -13,7 +13,7 @@ parser. It returns when there's nothing more it can do with the available
...
@@ -13,7 +13,7 @@ parser. It returns when there's nothing more it can do with the available
data. When you have no more data to push into the parser, call .close().
data. When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.
This completes the parsing and returns the root message object.
The other advantage of this parser is that it will never
throw
a parsing
The other advantage of this parser is that it will never
raise
a parsing
exception. Instead, when it finds something unexpected, it adds a 'defect' to
exception. Instead, when it finds something unexpected, it adds a 'defect' to
the current message. Defects are just instances that live on the message
the current message. Defects are just instances that live on the message
object's .defects attribute.
object's .defects attribute.
...
@@ -214,7 +214,7 @@ class FeedParser:
...
@@ -214,7 +214,7 @@ class FeedParser:
# supposed to see in the body of the message.
# supposed to see in the body of the message.
self
.
_parse_headers
(
headers
)
self
.
_parse_headers
(
headers
)
# Headers-only parsing is a backwards compatibility hack, which was
# Headers-only parsing is a backwards compatibility hack, which was
# necessary in the older parser, which could
throw
errors. All
# necessary in the older parser, which could
raise
errors. All
# remaining lines in the input are thrown into the message body.
# remaining lines in the input are thrown into the message body.
if
self
.
_headersonly
:
if
self
.
_headersonly
:
lines
=
[]
lines
=
[]
...
...
Lib/email/header.py
View file @
737fb89d
...
@@ -280,7 +280,7 @@ class Header:
...
@@ -280,7 +280,7 @@ class Header:
else
:
else
:
s
=
s
.
decode
(
input_charset
,
errors
)
s
=
s
.
decode
(
input_charset
,
errors
)
# Ensure that the bytes we're storing can be decoded to the output
# Ensure that the bytes we're storing can be decoded to the output
# character set, otherwise an early error is
thrown
.
# character set, otherwise an early error is
raised
.
output_charset
=
charset
.
output_codec
or
'us-ascii'
output_charset
=
charset
.
output_codec
or
'us-ascii'
if
output_charset
!=
_charset
.
UNKNOWN8BIT
:
if
output_charset
!=
_charset
.
UNKNOWN8BIT
:
try
:
try
:
...
...
Lib/importlib/_bootstrap.py
View file @
737fb89d
...
@@ -415,7 +415,7 @@ class SourceLoader(_LoaderBasics):
...
@@ -415,7 +415,7 @@ class SourceLoader(_LoaderBasics):
source_mtime
is
not
None
):
source_mtime
is
not
None
):
# If e.g. Jython ever implements imp.cache_from_source to have
# If e.g. Jython ever implements imp.cache_from_source to have
# their own cached file format, this block of code will most likely
# their own cached file format, this block of code will most likely
#
throw
an exception.
#
raise
an exception.
data
=
bytearray
(
imp
.
get_magic
())
data
=
bytearray
(
imp
.
get_magic
())
data
.
extend
(
marshal
.
_w_long
(
source_mtime
))
data
.
extend
(
marshal
.
_w_long
(
source_mtime
))
data
.
extend
(
marshal
.
dumps
(
code_object
))
data
.
extend
(
marshal
.
dumps
(
code_object
))
...
...
Lib/importlib/test/import_/test_fromlist.py
View file @
737fb89d
...
@@ -39,7 +39,7 @@ class HandlingFromlist(unittest.TestCase):
...
@@ -39,7 +39,7 @@ class HandlingFromlist(unittest.TestCase):
If a package is being imported, then what is listed in fromlist may be
If a package is being imported, then what is listed in fromlist may be
treated as a module to be imported [module]. But once again, even if
treated as a module to be imported [module]. But once again, even if
something in fromlist does not exist as a module, no error is
thrown
something in fromlist does not exist as a module, no error is
raised
[no module]. And this extends to what is contained in __all__ when '*' is
[no module]. And this extends to what is contained in __all__ when '*' is
imported [using *]. And '*' does not need to be the only name in the
imported [using *]. And '*' does not need to be the only name in the
fromlist [using * with others].
fromlist [using * with others].
...
...
Lib/io.py
View file @
737fb89d
...
@@ -4,7 +4,7 @@ builtin open function is defined in this module.
...
@@ -4,7 +4,7 @@ builtin open function is defined in this module.
At the top of the I/O hierarchy is the abstract base class IOBase. It
At the top of the I/O hierarchy is the abstract base class IOBase. It
defines the basic interface to a stream. Note, however, that there is no
defines the basic interface to a stream. Note, however, that there is no
separation between reading and writing to streams; implementations are
separation between reading and writing to streams; implementations are
allowed to
throw
an IOError if they do not support a given operation.
allowed to
raise
an IOError if they do not support a given operation.
Extending IOBase is RawIOBase which deals simply with the reading and
Extending IOBase is RawIOBase which deals simply with the reading and
writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide
writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide
...
...
Lib/logging/__init__.py
View file @
737fb89d
...
@@ -1355,7 +1355,7 @@ class Logger(Filterer):
...
@@ -1355,7 +1355,7 @@ class Logger(Filterer):
"""
"""
sinfo
=
None
sinfo
=
None
if
_srcfile
:
if
_srcfile
:
#IronPython doesn't track Python frames, so findCaller
throw
s an
#IronPython doesn't track Python frames, so findCaller
raise
s an
#exception on some versions of IronPython. We trap it here so that
#exception on some versions of IronPython. We trap it here so that
#IronPython can use logging.
#IronPython can use logging.
try
:
try
:
...
...
Lib/multiprocessing/util.py
View file @
737fb89d
...
@@ -301,7 +301,7 @@ def _exit_function(info=info, debug=debug, _run_finalizers=_run_finalizers,
...
@@ -301,7 +301,7 @@ def _exit_function(info=info, debug=debug, _run_finalizers=_run_finalizers,
_run_finalizers
(
0
)
_run_finalizers
(
0
)
if
current_process
()
is
not
None
:
if
current_process
()
is
not
None
:
# We check if the current process is None here because if
# We check if the current process is None here because if
# it's None, any call to ``active_children()`` will
throw
an
# it's None, any call to ``active_children()`` will
raise
an
# AttributeError (active_children winds up trying to get
# AttributeError (active_children winds up trying to get
# attributes from util._current_process). This happens in a
# attributes from util._current_process). This happens in a
# variety of shutdown circumstances that are not well-understood
# variety of shutdown circumstances that are not well-understood
...
...
Lib/runpy.py
View file @
737fb89d
...
@@ -211,7 +211,7 @@ def _get_importer(path_name):
...
@@ -211,7 +211,7 @@ def _get_importer(path_name):
pass
pass
else
:
else
:
# The following check looks a bit odd. The trick is that
# The following check looks a bit odd. The trick is that
# NullImporter
throw
s ImportError if the supplied path is a
# NullImporter
raise
s ImportError if the supplied path is a
# *valid* directory entry (and hence able to be handled
# *valid* directory entry (and hence able to be handled
# by the standard import machinery)
# by the standard import machinery)
try
:
try
:
...
...
Lib/tempfile.py
View file @
737fb89d
...
@@ -625,7 +625,7 @@ class TemporaryDirectory(object):
...
@@ -625,7 +625,7 @@ class TemporaryDirectory(object):
def
__init__
(
self
,
suffix
=
""
,
prefix
=
template
,
dir
=
None
):
def
__init__
(
self
,
suffix
=
""
,
prefix
=
template
,
dir
=
None
):
self
.
_closed
=
False
self
.
_closed
=
False
self
.
name
=
None
# Handle mkdtemp
throw
ing an exception
self
.
name
=
None
# Handle mkdtemp
rais
ing an exception
self
.
name
=
mkdtemp
(
suffix
,
prefix
,
dir
)
self
.
name
=
mkdtemp
(
suffix
,
prefix
,
dir
)
def
__repr__
(
self
):
def
__repr__
(
self
):
...
...
Lib/test/test_codeop.py
View file @
737fb89d
...
@@ -50,7 +50,7 @@ class CodeopTests(unittest.TestCase):
...
@@ -50,7 +50,7 @@ class CodeopTests(unittest.TestCase):
'''succeed iff str is the start of an invalid piece of code'''
'''succeed iff str is the start of an invalid piece of code'''
try
:
try
:
compile_command
(
str
,
symbol
=
symbol
)
compile_command
(
str
,
symbol
=
symbol
)
self
.
fail
(
"No exception
thrown
for invalid code"
)
self
.
fail
(
"No exception
raised
for invalid code"
)
except
SyntaxError
:
except
SyntaxError
:
self
.
assertTrue
(
is_syntax
)
self
.
assertTrue
(
is_syntax
)
except
OverflowError
:
except
OverflowError
:
...
...
Lib/test/test_docxmlrpc.py
View file @
737fb89d
...
@@ -100,7 +100,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
...
@@ -100,7 +100,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
self
.
assertEqual
(
response
.
status
,
200
)
self
.
assertEqual
(
response
.
status
,
200
)
self
.
assertEqual
(
response
.
getheader
(
"Content-type"
),
"text/html"
)
self
.
assertEqual
(
response
.
getheader
(
"Content-type"
),
"text/html"
)
# Server
throw
s an exception if we don't start to read the data
# Server
raise
s an exception if we don't start to read the data
response
.
read
()
response
.
read
()
def
test_invalid_get_response
(
self
):
def
test_invalid_get_response
(
self
):
...
...
Lib/test/test_imaplib.py
View file @
737fb89d
...
@@ -99,7 +99,7 @@ class SimpleIMAPHandler(socketserver.StreamRequestHandler):
...
@@ -99,7 +99,7 @@ class SimpleIMAPHandler(socketserver.StreamRequestHandler):
return
return
line
+=
part
line
+=
part
except
IOError
:
except
IOError
:
# ..but SSLSockets
throw
exceptions.
# ..but SSLSockets
raise
exceptions.
return
return
if
line
.
endswith
(
b'
\
r
\
n
'
):
if
line
.
endswith
(
b'
\
r
\
n
'
):
break
break
...
...
Lib/test/test_minidom.py
View file @
737fb89d
...
@@ -1085,7 +1085,7 @@ class MinidomTest(unittest.TestCase):
...
@@ -1085,7 +1085,7 @@ class MinidomTest(unittest.TestCase):
self
.
assertEqual
(
doc
.
toxml
(
'iso-8859-15'
),
self
.
assertEqual
(
doc
.
toxml
(
'iso-8859-15'
),
b'<?xml version="1.0" encoding="iso-8859-15"?><foo>
\
xa4
</foo>'
)
b'<?xml version="1.0" encoding="iso-8859-15"?><foo>
\
xa4
</foo>'
)
# Verify that character decoding errors
throw
exceptions instead
# Verify that character decoding errors
raise
exceptions instead
# of crashing
# of crashing
self
.
assertRaises
(
UnicodeDecodeError
,
parseString
,
self
.
assertRaises
(
UnicodeDecodeError
,
parseString
,
b'<fran
\
xe7
ais>Comment
\
xe7
a va ? Tr
\
xe8
s bien ?</fran
\
xe7
ais>'
)
b'<fran
\
xe7
ais>Comment
\
xe7
a va ? Tr
\
xe8
s bien ?</fran
\
xe7
ais>'
)
...
...
Lib/test/test_os.py
View file @
737fb89d
...
@@ -164,33 +164,33 @@ class StatAttributeTests(unittest.TestCase):
...
@@ -164,33 +164,33 @@ class StatAttributeTests(unittest.TestCase):
try
:
try
:
result
[
200
]
result
[
200
]
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
IndexError
:
except
IndexError
:
pass
pass
# Make sure that assignment fails
# Make sure that assignment fails
try
:
try
:
result
.
st_mode
=
1
result
.
st_mode
=
1
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
AttributeError
:
except
AttributeError
:
pass
pass
try
:
try
:
result
.
st_rdev
=
1
result
.
st_rdev
=
1
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
(
AttributeError
,
TypeError
):
except
(
AttributeError
,
TypeError
):
pass
pass
try
:
try
:
result
.
parrot
=
1
result
.
parrot
=
1
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
AttributeError
:
except
AttributeError
:
pass
pass
# Use the stat_result constructor with a too-short tuple.
# Use the stat_result constructor with a too-short tuple.
try
:
try
:
result2
=
os
.
stat_result
((
10
,))
result2
=
os
.
stat_result
((
10
,))
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
TypeError
:
except
TypeError
:
pass
pass
...
@@ -233,20 +233,20 @@ class StatAttributeTests(unittest.TestCase):
...
@@ -233,20 +233,20 @@ class StatAttributeTests(unittest.TestCase):
# Make sure that assignment really fails
# Make sure that assignment really fails
try
:
try
:
result
.
f_bfree
=
1
result
.
f_bfree
=
1
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
AttributeError
:
except
AttributeError
:
pass
pass
try
:
try
:
result
.
parrot
=
1
result
.
parrot
=
1
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
AttributeError
:
except
AttributeError
:
pass
pass
# Use the constructor with a too-short tuple.
# Use the constructor with a too-short tuple.
try
:
try
:
result2
=
os
.
statvfs_result
((
10
,))
result2
=
os
.
statvfs_result
((
10
,))
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
TypeError
:
except
TypeError
:
pass
pass
...
...
Lib/test/test_pty.py
View file @
737fb89d
...
@@ -152,7 +152,7 @@ class PtyTest(unittest.TestCase):
...
@@ -152,7 +152,7 @@ class PtyTest(unittest.TestCase):
# platform-dependent amount of data is written to its fd. On
# platform-dependent amount of data is written to its fd. On
# Linux 2.6, it's 4000 bytes and the child won't block, but on OS
# Linux 2.6, it's 4000 bytes and the child won't block, but on OS
# X even the small writes in the child above will block it. Also
# X even the small writes in the child above will block it. Also
# on Linux, the read() will
throw
an OSError (input/output error)
# on Linux, the read() will
raise
an OSError (input/output error)
# when it tries to read past the end of the buffer but the child's
# when it tries to read past the end of the buffer but the child's
# already exited, so catch and discard those exceptions. It's not
# already exited, so catch and discard those exceptions. It's not
# worth checking for EIO.
# worth checking for EIO.
...
...
Lib/test/test_sax.py
View file @
737fb89d
...
@@ -389,7 +389,7 @@ class XmlgenTest(unittest.TestCase):
...
@@ -389,7 +389,7 @@ class XmlgenTest(unittest.TestCase):
def
test_5027_1
(
self
):
def
test_5027_1
(
self
):
# The xml prefix (as in xml:lang below) is reserved and bound by
# The xml prefix (as in xml:lang below) is reserved and bound by
# definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had
# definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had
# a bug whereby a KeyError is
thrown
because this namespace is missing
# a bug whereby a KeyError is
raised
because this namespace is missing
# from a dictionary.
# from a dictionary.
#
#
# This test demonstrates the bug by parsing a document.
# This test demonstrates the bug by parsing a document.
...
@@ -415,7 +415,7 @@ class XmlgenTest(unittest.TestCase):
...
@@ -415,7 +415,7 @@ class XmlgenTest(unittest.TestCase):
def
test_5027_2
(
self
):
def
test_5027_2
(
self
):
# The xml prefix (as in xml:lang below) is reserved and bound by
# The xml prefix (as in xml:lang below) is reserved and bound by
# definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had
# definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had
# a bug whereby a KeyError is
thrown
because this namespace is missing
# a bug whereby a KeyError is
raised
because this namespace is missing
# from a dictionary.
# from a dictionary.
#
#
# This test demonstrates the bug by direct manipulation of the
# This test demonstrates the bug by direct manipulation of the
...
...
Lib/test/test_signal.py
View file @
737fb89d
...
@@ -113,7 +113,7 @@ class InterProcessSignalTests(unittest.TestCase):
...
@@ -113,7 +113,7 @@ class InterProcessSignalTests(unittest.TestCase):
# This wait should be interrupted by the signal's exception.
# This wait should be interrupted by the signal's exception.
self
.
wait
(
child
)
self
.
wait
(
child
)
time
.
sleep
(
1
)
# Give the signal time to be delivered.
time
.
sleep
(
1
)
# Give the signal time to be delivered.
self
.
fail
(
'HandlerBCalled exception not
thrown
'
)
self
.
fail
(
'HandlerBCalled exception not
raised
'
)
except
HandlerBCalled
:
except
HandlerBCalled
:
self
.
assertTrue
(
self
.
b_called
)
self
.
assertTrue
(
self
.
b_called
)
self
.
assertFalse
(
self
.
a_called
)
self
.
assertFalse
(
self
.
a_called
)
...
@@ -152,7 +152,7 @@ class InterProcessSignalTests(unittest.TestCase):
...
@@ -152,7 +152,7 @@ class InterProcessSignalTests(unittest.TestCase):
# test-running process from all the signals. It then
# test-running process from all the signals. It then
# communicates with that child process over a pipe and
# communicates with that child process over a pipe and
# re-raises information about any exceptions the child
# re-raises information about any exceptions the child
#
throw
s. The real work happens in self.run_test().
#
raise
s. The real work happens in self.run_test().
os_done_r
,
os_done_w
=
os
.
pipe
()
os_done_r
,
os_done_w
=
os
.
pipe
()
with
closing
(
os
.
fdopen
(
os_done_r
,
'rb'
))
as
done_r
,
\
with
closing
(
os
.
fdopen
(
os_done_r
,
'rb'
))
as
done_r
,
\
closing
(
os
.
fdopen
(
os_done_w
,
'wb'
))
as
done_w
:
closing
(
os
.
fdopen
(
os_done_w
,
'wb'
))
as
done_w
:
...
...
Lib/test/test_socketserver.py
View file @
737fb89d
...
@@ -58,7 +58,7 @@ if HAVE_UNIX_SOCKETS:
...
@@ -58,7 +58,7 @@ if HAVE_UNIX_SOCKETS:
def
simple_subprocess
(
testcase
):
def
simple_subprocess
(
testcase
):
pid
=
os
.
fork
()
pid
=
os
.
fork
()
if
pid
==
0
:
if
pid
==
0
:
# Don't
throw
an exception; it would be caught by the test harness.
# Don't
raise
an exception; it would be caught by the test harness.
os
.
_exit
(
72
)
os
.
_exit
(
72
)
yield
None
yield
None
pid2
,
status
=
os
.
waitpid
(
pid
,
0
)
pid2
,
status
=
os
.
waitpid
(
pid
,
0
)
...
...
Lib/test/test_sys_settrace.py
View file @
737fb89d
...
@@ -418,7 +418,7 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
...
@@ -418,7 +418,7 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
except
ValueError
:
except
ValueError
:
pass
pass
else
:
else
:
self
.
fail
(
"exception not
thrown
!"
)
self
.
fail
(
"exception not
raised
!"
)
except
RuntimeError
:
except
RuntimeError
:
self
.
fail
(
"recursion counter not reset"
)
self
.
fail
(
"recursion counter not reset"
)
...
...
Lib/test/test_time.py
View file @
737fb89d
...
@@ -106,7 +106,7 @@ class TimeTestCase(unittest.TestCase):
...
@@ -106,7 +106,7 @@ class TimeTestCase(unittest.TestCase):
def
test_strptime
(
self
):
def
test_strptime
(
self
):
# Should be able to go round-trip from strftime to strptime without
# Should be able to go round-trip from strftime to strptime without
#
throw
ing an exception.
#
rais
ing an exception.
tt
=
time
.
gmtime
(
self
.
t
)
tt
=
time
.
gmtime
(
self
.
t
)
for
directive
in
(
'a'
,
'A'
,
'b'
,
'B'
,
'c'
,
'd'
,
'H'
,
'I'
,
for
directive
in
(
'a'
,
'A'
,
'b'
,
'B'
,
'c'
,
'd'
,
'H'
,
'I'
,
'j'
,
'm'
,
'M'
,
'p'
,
'S'
,
'j'
,
'm'
,
'M'
,
'p'
,
'S'
,
...
...
Lib/test/test_uu.py
View file @
737fb89d
...
@@ -80,7 +80,7 @@ class UUTest(unittest.TestCase):
...
@@ -80,7 +80,7 @@ class UUTest(unittest.TestCase):
out
=
io
.
BytesIO
()
out
=
io
.
BytesIO
()
try
:
try
:
uu
.
decode
(
inp
,
out
)
uu
.
decode
(
inp
,
out
)
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
uu
.
Error
as
e
:
except
uu
.
Error
as
e
:
self
.
assertEqual
(
str
(
e
),
"Truncated input file"
)
self
.
assertEqual
(
str
(
e
),
"Truncated input file"
)
...
@@ -89,7 +89,7 @@ class UUTest(unittest.TestCase):
...
@@ -89,7 +89,7 @@ class UUTest(unittest.TestCase):
out
=
io
.
BytesIO
()
out
=
io
.
BytesIO
()
try
:
try
:
uu
.
decode
(
inp
,
out
)
uu
.
decode
(
inp
,
out
)
self
.
fail
(
"No exception
thrown
"
)
self
.
fail
(
"No exception
raised
"
)
except
uu
.
Error
as
e
:
except
uu
.
Error
as
e
:
self
.
assertEqual
(
str
(
e
),
"No valid begin line found in input file"
)
self
.
assertEqual
(
str
(
e
),
"No valid begin line found in input file"
)
...
...
Lib/test/test_winreg.py
View file @
737fb89d
...
@@ -245,7 +245,7 @@ class LocalWinregTests(BaseWinregTests):
...
@@ -245,7 +245,7 @@ class LocalWinregTests(BaseWinregTests):
def
test_changing_value
(
self
):
def
test_changing_value
(
self
):
# Issue2810: A race condition in 2.6 and 3.1 may cause
# Issue2810: A race condition in 2.6 and 3.1 may cause
# EnumValue or QueryValue to
throw
"WindowsError: More data is
# EnumValue or QueryValue to
raise
"WindowsError: More data is
# available"
# available"
done
=
False
done
=
False
...
@@ -291,7 +291,7 @@ class LocalWinregTests(BaseWinregTests):
...
@@ -291,7 +291,7 @@ class LocalWinregTests(BaseWinregTests):
def
test_dynamic_key
(
self
):
def
test_dynamic_key
(
self
):
# Issue2810, when the value is dynamically generated, these
# Issue2810, when the value is dynamically generated, these
#
throw
"WindowsError: More data is available" in 2.6 and 3.1
#
raise
"WindowsError: More data is available" in 2.6 and 3.1
try
:
try
:
EnumValue
(
HKEY_PERFORMANCE_DATA
,
0
)
EnumValue
(
HKEY_PERFORMANCE_DATA
,
0
)
except
OSError
as
e
:
except
OSError
as
e
:
...
...
Lib/test/test_zipfile.py
View file @
737fb89d
...
@@ -873,7 +873,7 @@ class OtherTests(unittest.TestCase):
...
@@ -873,7 +873,7 @@ class OtherTests(unittest.TestCase):
with
zipfile
.
ZipFile
(
data
,
mode
=
"w"
)
as
zipf
:
with
zipfile
.
ZipFile
(
data
,
mode
=
"w"
)
as
zipf
:
zipf
.
writestr
(
"foo.txt"
,
"O, for a Muse of Fire!"
)
zipf
.
writestr
(
"foo.txt"
,
"O, for a Muse of Fire!"
)
# This is correct; calling .read on a closed ZipFile should
throw
# This is correct; calling .read on a closed ZipFile should
raise
# a RuntimeError, and so should calling .testzip. An earlier
# a RuntimeError, and so should calling .testzip. An earlier
# version of .testzip would swallow this exception (and any other)
# version of .testzip would swallow this exception (and any other)
# and report that the first file in the archive was corrupt.
# and report that the first file in the archive was corrupt.
...
...
Lib/tkinter/__init__.py
View file @
737fb89d
...
@@ -147,7 +147,7 @@ def _tkerror(err):
...
@@ -147,7 +147,7 @@ def _tkerror(err):
pass
pass
def
_exit
(
code
=
0
):
def
_exit
(
code
=
0
):
"""Internal function. Calling it will
throw
the exception SystemExit."""
"""Internal function. Calling it will
raise
the exception SystemExit."""
try
:
try
:
code
=
int
(
code
)
code
=
int
(
code
)
except
ValueError
:
except
ValueError
:
...
...
Lib/unittest/case.py
View file @
737fb89d
...
@@ -528,10 +528,10 @@ class TestCase(object):
...
@@ -528,10 +528,10 @@ class TestCase(object):
def
assertRaises
(
self
,
excClass
,
callableObj
=
None
,
*
args
,
**
kwargs
):
def
assertRaises
(
self
,
excClass
,
callableObj
=
None
,
*
args
,
**
kwargs
):
"""Fail unless an exception of class excClass is
thrown
"""Fail unless an exception of class excClass is
raised
by callableObj when invoked with arguments args and keyword
by callableObj when invoked with arguments args and keyword
arguments kwargs. If a different type of exception is
arguments kwargs. If a different type of exception is
thrown
, it will not be caught, and the test case will be
raised
, it will not be caught, and the test case will be
deemed to have suffered an error, exactly as for an
deemed to have suffered an error, exactly as for an
unexpected exception.
unexpected exception.
...
...
Lib/wsgiref/validate.py
View file @
737fb89d
...
@@ -139,9 +139,9 @@ def validator(application):
...
@@ -139,9 +139,9 @@ def validator(application):
When applied between a WSGI server and a WSGI application, this
When applied between a WSGI server and a WSGI application, this
middleware will check for WSGI compliancy on a number of levels.
middleware will check for WSGI compliancy on a number of levels.
This middleware does not modify the request or response in any
This middleware does not modify the request or response in any
way, but will
throw
an AssertionError if anything seems off
way, but will
raise
an AssertionError if anything seems off
(except for a failure to close the application iterator, which
(except for a failure to close the application iterator, which
will be printed to stderr -- there'
s
no
way
to
throw
an
exception
will be printed to stderr -- there'
s
no
way
to
raise
an
exception
at
that
point
).
at
that
point
).
"""
"""
...
...
Lib/xml/sax/_exceptions.py
View file @
737fb89d
...
@@ -12,7 +12,7 @@ class SAXException(Exception):
...
@@ -12,7 +12,7 @@ class SAXException(Exception):
the application: you can subclass it to provide additional
the application: you can subclass it to provide additional
functionality, or to add localization. Note that although you will
functionality, or to add localization. Note that although you will
receive a SAXException as the argument to the handlers in the
receive a SAXException as the argument to the handlers in the
ErrorHandler interface, you are not actually required to
throw
ErrorHandler interface, you are not actually required to
raise
the exception; instead, you can simply read the information in
the exception; instead, you can simply read the information in
it."""
it."""
...
@@ -50,7 +50,7 @@ class SAXParseException(SAXException):
...
@@ -50,7 +50,7 @@ class SAXParseException(SAXException):
the original XML document. Note that although the application will
the original XML document. Note that although the application will
receive a SAXParseException as the argument to the handlers in the
receive a SAXParseException as the argument to the handlers in the
ErrorHandler interface, the application is not actually required
ErrorHandler interface, the application is not actually required
to
throw
the exception; instead, it can simply read the
to
raise
the exception; instead, it can simply read the
information in it and take a different action.
information in it and take a different action.
Since this exception is a subclass of SAXException, it inherits
Since this exception is a subclass of SAXException, it inherits
...
@@ -62,7 +62,7 @@ class SAXParseException(SAXException):
...
@@ -62,7 +62,7 @@ class SAXParseException(SAXException):
self
.
_locator
=
locator
self
.
_locator
=
locator
# We need to cache this stuff at construction time.
# We need to cache this stuff at construction time.
# If this exception is
thrown
, the objects through which we must
# If this exception is
raised
, the objects through which we must
# traverse to get this information may be deleted by the time
# traverse to get this information may be deleted by the time
# it gets caught.
# it gets caught.
self
.
_systemId
=
self
.
_locator
.
getSystemId
()
self
.
_systemId
=
self
.
_locator
.
getSystemId
()
...
...
Lib/xml/sax/xmlreader.py
View file @
737fb89d
...
@@ -68,7 +68,7 @@ class XMLReader:
...
@@ -68,7 +68,7 @@ class XMLReader:
SAX parsers are not required to provide localization for errors
SAX parsers are not required to provide localization for errors
and warnings; if they cannot support the requested locale,
and warnings; if they cannot support the requested locale,
however, they must
throw
a SAX exception. Applications may
however, they must
raise
a SAX exception. Applications may
request a locale change in the middle of a parse."""
request a locale change in the middle of a parse."""
raise
SAXNotSupportedException
(
"Locale support not implemented"
)
raise
SAXNotSupportedException
(
"Locale support not implemented"
)
...
...
Lib/xmlrpc/client.py
View file @
737fb89d
...
@@ -800,7 +800,7 @@ class _MultiCallMethod:
...
@@ -800,7 +800,7 @@ class _MultiCallMethod:
class
MultiCallIterator
:
class
MultiCallIterator
:
"""Iterates over the results of a multicall. Exceptions are
"""Iterates over the results of a multicall. Exceptions are
thrown
in response to xmlrpc faults."""
raised
in response to xmlrpc faults."""
def
__init__
(
self
,
results
):
def
__init__
(
self
,
results
):
self
.
results
=
results
self
.
results
=
results
...
...
Modules/_io/_iomodule.c
View file @
737fb89d
...
@@ -59,7 +59,7 @@ PyDoc_STRVAR(module_doc,
...
@@ -59,7 +59,7 @@ PyDoc_STRVAR(module_doc,
"At the top of the I/O hierarchy is the abstract base class IOBase. It
\n
"
"At the top of the I/O hierarchy is the abstract base class IOBase. It
\n
"
"defines the basic interface to a stream. Note, however, that there is no
\n
"
"defines the basic interface to a stream. Note, however, that there is no
\n
"
"separation between reading and writing to streams; implementations are
\n
"
"separation between reading and writing to streams; implementations are
\n
"
"allowed to
throw
an IOError if they do not support a given operation.
\n
"
"allowed to
raise
an IOError if they do not support a given operation.
\n
"
"
\n
"
"
\n
"
"Extending IOBase is RawIOBase which deals simply with the reading and
\n
"
"Extending IOBase is RawIOBase which deals simply with the reading and
\n
"
"writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide
\n
"
"writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide
\n
"
...
...
Modules/parsermodule.c
View file @
737fb89d
...
@@ -718,7 +718,7 @@ parser_tuple2st(PyST_Object *self, PyObject *args, PyObject *kw)
...
@@ -718,7 +718,7 @@ parser_tuple2st(PyST_Object *self, PyObject *args, PyObject *kw)
err_string
(
"parse tree does not use a valid start symbol"
);
err_string
(
"parse tree does not use a valid start symbol"
);
}
}
}
}
/* Make sure we
throw
an exception on all errors. We should never
/* Make sure we
raise
an exception on all errors. We should never
* get this, but we'd do well to be sure something is done.
* get this, but we'd do well to be sure something is done.
*/
*/
if
(
st
==
NULL
&&
!
PyErr_Occurred
())
if
(
st
==
NULL
&&
!
PyErr_Occurred
())
...
@@ -824,7 +824,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
...
@@ -824,7 +824,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
else
if
(
!
ISNONTERMINAL
(
type
))
{
else
if
(
!
ISNONTERMINAL
(
type
))
{
/*
/*
* It has to be one or the other; this is an error.
* It has to be one or the other; this is an error.
*
Throw
an exception.
*
Raise
an exception.
*/
*/
PyObject
*
err
=
Py_BuildValue
(
"os"
,
elem
,
"unknown node type."
);
PyObject
*
err
=
Py_BuildValue
(
"os"
,
elem
,
"unknown node type."
);
PyErr_SetObject
(
parser_error
,
err
);
PyErr_SetObject
(
parser_error
,
err
);
...
@@ -876,7 +876,7 @@ build_node_tree(PyObject *tuple)
...
@@ -876,7 +876,7 @@ build_node_tree(PyObject *tuple)
if
(
ISTERMINAL
(
num
))
{
if
(
ISTERMINAL
(
num
))
{
/*
/*
* The tuple is simple, but it doesn't start with a start symbol.
* The tuple is simple, but it doesn't start with a start symbol.
*
Throw
an exception now and be done with it.
*
Raise
an exception now and be done with it.
*/
*/
tuple
=
Py_BuildValue
(
"os"
,
tuple
,
tuple
=
Py_BuildValue
(
"os"
,
tuple
,
"Illegal syntax-tree; cannot start with terminal symbol."
);
"Illegal syntax-tree; cannot start with terminal symbol."
);
...
...
Modules/posixmodule.c
View file @
737fb89d
...
@@ -349,7 +349,7 @@ static int win32_can_symlink = 0;
...
@@ -349,7 +349,7 @@ static int win32_can_symlink = 0;
#if defined _MSC_VER && _MSC_VER >= 1400
#if defined _MSC_VER && _MSC_VER >= 1400
/* Microsoft CRT in VS2005 and higher will verify that a filehandle is
/* Microsoft CRT in VS2005 and higher will verify that a filehandle is
* valid and
throw
an assertion if it isn't.
* valid and
raise
an assertion if it isn't.
* Normally, an invalid fd is likely to be a C program error and therefore
* Normally, an invalid fd is likely to be a C program error and therefore
* an assertion can be useful, but it does contradict the POSIX standard
* an assertion can be useful, but it does contradict the POSIX standard
* which for write(2) states:
* which for write(2) states:
...
...
Tools/scripts/serve.py
View file @
737fb89d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
'''
'''
Small wsgiref based web server. Takes a path to serve from and an
Small wsgiref based web server. Takes a path to serve from and an
optional port number (defaults to 8000), then tries to serve files.
optional port number (defaults to 8000), then tries to serve files.
Mime types are guessed from the file names, 404 errors are
thrown
Mime types are guessed from the file names, 404 errors are
raised
if the file is not found. Used for the make serve target in Doc.
if the file is not found. Used for the make serve target in Doc.
'''
'''
import
sys
import
sys
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment