Skip to content

Commit d3049db

Browse files
committed
Exercise input from the result audit hook
Retain the newly merged standard-stream audit behavior across the shared-reader rebase. Assisted-by: OpenAI Codex:model-version-unavailable
1 parent a093255 commit d3049db

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎extra_tests/snippets/stdlib_input_readline.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,20 @@ def first():
102102
""",
103103
output_terminal=True,
104104
)
105+
106+
# The result audit runs after native reading and may start another input.
107+
# It must not inherit an active reader borrow or lose the retained next line.
108+
exercise(
109+
"""
110+
import sys
111+
results = []
112+
def audit(event, args):
113+
if event == 'builtins.input/result' and not results:
114+
results.append(args[0])
115+
results.append(input('SECOND>'))
116+
sys.addaudithook(audit)
117+
assert input('FIRST>') == 'one'
118+
assert results == ['one', 'two'], results
119+
print('RESULT=' + results[1], flush=True)
120+
"""
121+
)

0 commit comments

Comments
 (0)