]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-123240: Raise input audit events in the new REPL (#123274)
authorsobolevn <mail@sobolevn.me>
Thu, 5 Sep 2024 15:17:24 +0000 (18:17 +0300)
committerGitHub <noreply@github.com>
Thu, 5 Sep 2024 15:17:24 +0000 (17:17 +0200)
Lib/_pyrepl/readline.py
Misc/NEWS.d/next/Library/2024-08-24-00-03-01.gh-issue-123240.uFPG3l.rst [new file with mode: 0644]

index 483eb1039fa062df94b169863116725c53fd9fb9..dfacfd84999136362f4f17f021aa4cdf2156d098 100644 (file)
@@ -365,8 +365,12 @@ class _ReadlineWrapper:
         except _error:
             assert raw_input is not None
             return raw_input(prompt)
-        reader.ps1 = str(prompt)
-        return reader.readline(startup_hook=self.startup_hook)
+        prompt_str = str(prompt)
+        reader.ps1 = prompt_str
+        sys.audit("builtins.input", prompt_str)
+        result = reader.readline(startup_hook=self.startup_hook)
+        sys.audit("builtins.input/result", result)
+        return result
 
     def multiline_input(self, more_lines: MoreLinesCallable, ps1: str, ps2: str) -> str:
         """Read an input on possibly multiple lines, asking for more
diff --git a/Misc/NEWS.d/next/Library/2024-08-24-00-03-01.gh-issue-123240.uFPG3l.rst b/Misc/NEWS.d/next/Library/2024-08-24-00-03-01.gh-issue-123240.uFPG3l.rst
new file mode 100644 (file)
index 0000000..e6ea6c3
--- /dev/null
@@ -0,0 +1 @@
+Raise audit events for the :func:`input` in the new REPL.