diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/sys.rst | 6 | ||||
-rw-r--r-- | Doc/tools/extensions/pyspecific.py | 22 | ||||
-rw-r--r-- | Doc/using/cmdline.rst | 12 |
3 files changed, 31 insertions, 9 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 0b53ee0..a33e796 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -913,6 +913,12 @@ always available. read, so that you can set this hook there. The :mod:`site` module :ref:`sets this <rlcompleter-config>`. + .. audit-event:: cpython.run_interactivehook hook sys.__interactivehook__ + + Raises an :ref:`auditing event <auditing>` + ``cpython.run_interactivehook`` with the hook object as the argument when + the hook is called on startup. + .. versionadded:: 3.4 diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 9b38f8a..28b8bda 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -199,13 +199,18 @@ class AuditEvent(Directive): .format(name, info['args'], new_info['args']) ) - if len(self.arguments) >= 3 and self.arguments[2]: - target = self.arguments[2] - ids = [] - else: - target = "audit_event_{}_{}".format(name, len(info['source'])) - target = re.sub(r'\W', '_', label) - ids = [target] + ids = [] + try: + target = self.arguments[2].strip("\"'") + except (IndexError, TypeError): + target = None + if not target: + target = "audit_event_{}_{}".format( + re.sub(r'\W', '_', name), + len(info['source']), + ) + ids.append(target) + info['source'].append((env.docname, target)) pnode = nodes.paragraph(text, classes=["audit-hook"], ids=ids) @@ -560,7 +565,8 @@ def process_audit_events(app, doctree, fromdocname): row += nodes.entry('', node) node = nodes.paragraph() - for i, (doc, label) in enumerate(audit_event['source'], start=1): + backlinks = enumerate(sorted(set(audit_event['source'])), start=1) + for i, (doc, label) in backlinks: if isinstance(label, str): ref = nodes.reference("", nodes.Text("[{}]".format(i)), internal=True) ref['refuri'] = "{}#{}".format( diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 87af7e8..6bc440f 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -70,6 +70,7 @@ source. :data:`sys.path` (allowing modules in that directory to be imported as top level modules). + .. audit-event:: cpython.run_command command cmdoption-c .. cmdoption:: -m <module-name> @@ -106,13 +107,14 @@ source. python -mtimeit -s 'setup here' 'benchmarked code here' python -mtimeit -h # for details + .. audit-event:: cpython.run_module module-name cmdoption-m + .. seealso:: :func:`runpy.run_module` Equivalent functionality directly available to Python code :pep:`338` -- Executing modules as scripts - .. versionchanged:: 3.1 Supply the package name to run a ``__main__`` submodule. @@ -129,6 +131,7 @@ source. ``"-"`` and the current directory will be added to the start of :data:`sys.path`. + .. audit-event:: cpython.run_stdin "" "" .. describe:: <script> @@ -148,6 +151,8 @@ source. added to the start of :data:`sys.path` and the ``__main__.py`` file in that location is executed as the :mod:`__main__` module. + .. audit-event:: cpython.run_file filename + .. seealso:: :func:`runpy.run_path` Equivalent functionality directly available to Python code @@ -533,6 +538,11 @@ conflict. the interactive session. You can also change the prompts :data:`sys.ps1` and :data:`sys.ps2` and the hook :data:`sys.__interactivehook__` in this file. + .. audit-event:: cpython.run_startup filename PYTHONSTARTUP + + Raises an :ref:`auditing event <auditing>` ``cpython.run_startup`` with + the filename as the argument when called on startup. + .. envvar:: PYTHONOPTIMIZE |