Skip to content

Commit 6d7dfe0

Browse files
committed
Address feedback
1 parent 8ede9b2 commit 6d7dfe0

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎Lib/_pyrepl/simple_interact.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
from .readline import _get_reader, multiline_input, append_history_file
3434

3535

36-
# Called after the user submits a Python statement, but before it is executed.
37-
# The hook is not called for PyREPL commands such as ``clear``. Exceptions raised
38-
# by the hook and its return value are ignored. External tools such as IDEs can
39-
# install a hook to augment the behavior of the REPL.
36+
# Called with the complete statement, which may span multiple lines, after the
37+
# user submits it but before it is executed. The hook is not called for PyREPL
38+
# commands such as ``clear``. Exceptions raised by the hook and its return value
39+
# are ignored. External tools such as IDEs can install a hook to augment the
40+
# behavior of the REPL.
4041
#
4142
# For example, VS Code can mark the start of command execution:
4243
#

‎Lib/test/test_pyrepl/test_interact.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def fake_multiline_input(more_lines, ps1, ps2):
333333
return output.getvalue(), console.locals
334334

335335
def test_hook_called_before_statement_execution(self):
336-
statement = "print('statement executed')"
336+
statement = "if True:\n print('statement executed')\n"
337337
escape_sequence = "\x1b]633;C\x07"
338338
hook = MagicMock(
339339
side_effect=lambda statement: print(escape_sequence, end="")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Add an optional ``_pyrepl.pre_execution_hook`` callable that is invoked with
2-
the submitted source before each interactive statement is executed. This
3-
allows external tools to implement features such as shell integration.
1+
Add an optional ``_pyrepl.simple_interact.statement_submitted_hook`` callback
2+
that runs after a complete statement is submitted and before it is executed,
3+
allowing external tools to implement features such as shell integration.

0 commit comments

Comments
 (0)