8000 ExecFailure -> ExecutionFailed · python/cpython@6fc3380 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6fc3380

Browse files
ExecFailure -> ExecutionFailed
1 parent 2868f56 commit 6fc3380

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

Lib/test/support/interpreters/__init__.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
__all__ = [
1515
'get_current', 'get_main', 'create', 'list_all', 'is_shareable',
1616
'Interpreter',
17-
'InterpreterError', 'InterpreterNotFoundError',
18-
'ExecFailure', 'CallFailure',
17+
'InterpreterError', 'InterpreterNotFoundError', 'ExecutionFailed',
1918
'NotShareableError',
2019
'create_queue', 'Queue', 'QueueEmpty', 'QueueFull',
2120
]
@@ -44,7 +43,11 @@ def __getattr__(name):
4443
{formatted}
4544
""".strip()
4645

47-
class _ExecFailure(RuntimeError):
46+
class ExecutionFailed(RuntimeError):
47+
"""An unhandled exception happened during execution.
48+
49+
This is raised from Interpreter.exec() and Interpreter.call().
50+
"""
4851

4952
def __init__(self, excinfo):
5053
msg = excinfo.formatted
@@ -68,14 +71,6 @@ def __str__(self):
6871
)
6972

7073

71-
class ExecFailure(_ExecFailure):
72-
"""Raised from Interpreter.exec() for unhandled exceptions."""
73-
74-
75-
class CallFailure(_ExecFailure):
76-
"""Raised from Interpreter.call() for unhandled exceptions."""
77-
78-
7974
def create():
8075
"""Return a new (idle) Python interpreter."""
8176
id = _interpreters.create(isolated=True)
@@ -176,18 +171,18 @@ def exec(self, code, /):
176171
177172
There is no return value.
178173
179-
If the code raises an unhandled exception then an ExecFailure
180-
is raised, which summarizes the unhandled exception. The actual
181-
exception is discarded because objects cannot be shared between
182-
interpreters.
174+
If the code raises an unhandled exception then an ExecutionFailed
175+
exception is raised, which summarizes the unhandled exception.
176+
The actual exception is discarded because objects cannot be
177+
shared between interpreters.
183178
184179
This blocks the current Python thread until done. During
185180
that time, the previous interpreter is allowed to run
186181
in other threads.
187182
"""
188183
excinfo = _interpreters.exec(self._id, code)
189184
if excinfo is not None:
190-
raise ExecFailure(excinfo)
185+
raise ExecutionFailed(excinfo)
191186

192187
def call(self, callable, /):
193188
"""Call the object in the interpreter with given args/kwargs.
@@ -199,15 +194,15 @@ def call(self, callable, /):
199194
200195
If the callable raises an exception then the error display
201196
(including full traceback) is send back between the interpreters
202-
and a CallFailedError is raised, much like what happens with
203-
Interpreter.exec().
197+
and an ExecutionFailed exception is raised, much like what
198+
happens with Interpreter.exec().
204199
"""
205200
# XXX Support args and kwargs.
206201
# XXX Support arbitrary callables.
207202
# XXX Support returning the return value (e.g. via pickle).
208203
excinfo = _interpreters.call(self._id, callable)
209204
if excinfo is not None:
210-
raise CallFailure(excinfo)
205+
raise ExecutionFailed(excinfo)
211206

212207
def call_in_thread(self, callable, /, args=None, kwargs=None):
213208
"""Return a new thread that calls the object in the interpreter.

Lib/test/test_interpreters/test_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,9 @@ def test_not_shareable(self):
503503
interp.prepare_main(spam={'spam': 'eggs', 'foo': 'bar'})
504504

505505
# Make sure neither was actually bound.
506-
with self.assertRaises(interpreters.ExecFailure):
506+
with self.assertRaises(interpreters.ExecutionFailed):
507507
interp.exec('print(foo)')
508-
with self.assertRaises(interpreters.ExecFailure):
508+
with self.assertRaises(interpreters.ExecutionFailed):
509509
interp.exec('print(spam)')
510510

511511

@@ -522,7 +522,7 @@ def test_success(self):
522522

523523
def test_failure(self):
524524
interp = interpreters.create()
525-
with self.assertRaises(interpreters.ExecFailure):
525+
with self.assertRaises(interpreters.ExecutionFailed):
526526
interp.exec('raise Exception')
527527

528528
def test_display_preserved_exception(self):
@@ -555,8 +555,8 @@ def script():
555555
interp.exec(script)
556556
~~~~~~~~~~~^^^^^^^^
557557
{interpmod_line.strip()}
558-
raise ExecFailure(excinfo)
559-
test.support.interpreters.ExecFailure: RuntimeError: uh-oh!
558+
raise ExecutionFailed(excinfo)
559+
test.support.interpreters.ExecutionFailed: RuntimeError: uh-oh!
560560
561561
Uncaught in the interpreter:
562562
@@ -822,7 +822,7 @@ def test_call(self):
822822
raise Exception((args, kwargs))
823823
interp.call(callable)
824824

825-
with self.assertRaises(interpreters.CallFailure):
825+
with self.assertRaises(interpreters.ExecutionFailed):
826826
interp.call(call_func_failure)
827827

828828
def test_call_in_thread(self):

0 commit comments

Comments
 (0)
0