Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-119402: Add import/module audit event #119122

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

folded
Copy link

@folded folded commented May 17, 2024

This adds a balancing "import.complete" audit event matching the existing "import" audit event, which allows the audit system to be used to observe programatically the same import timing information that is logged by PYTHONPROFILEIMPORTTIME.

The current import audit event may be fired twice for imports of native modules. The second import event can be distinguished from the first because the second argument is always non-None in this case, whereas it is always None in the first case.

This adds a balancing "import.complete" audit event matching the existing
"import" audit event, which allows the audit system to be used to observe
programatically the same import timing information that is logged by
PYTHONPROFILEIMPORTTIME.

The current import audit event may be fired twice for imports of native
modules. The second import event can be distinguished from the first
because the second argument is always non-None in this case, whereas it
is always None in the first case.
Copy link

cpython-cla-bot bot commented May 17, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented May 17, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 17, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@folded folded marked this pull request as ready for review May 17, 2024 13:50
@folded
Copy link
Author

folded commented May 17, 2024

@zooba - Thomas Wouters suggested that you were a good person to tag on this change.

@nineteendo
Copy link
Contributor

Is this change small enough that it doesn't need an issue?

@bedevere-app
Copy link

bedevere-app bot commented May 20, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@folded
Copy link
Author

folded commented May 20, 2024

@nineteendo I'm not sure what the convention is here. I'm happy to create an issue if that's preferred. I'm also aware that there should be a documentation change, which I've added (I hope; the convention for documenting audit events isn't totally clear - especially when they need additional text).

Python/import.c Outdated Show resolved Hide resolved
Doc/reference/simple_stmts.rst Outdated Show resolved Hide resolved
Doc/reference/simple_stmts.rst Outdated Show resolved Hide resolved
@bedevere-app
Copy link

bedevere-app bot commented May 21, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 21, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Python/import.c Show resolved Hide resolved
Lib/test/audit-tests.py Outdated Show resolved Hide resolved
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
@bedevere-app
Copy link

bedevere-app bot commented May 22, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 22, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 22, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@zooba zooba changed the title Add import.complete audit event. gh-119402: Add import/module audit event May 22, 2024
@zooba
Copy link
Member

zooba commented May 22, 2024

This needs a NEWS entry (just a basic Adds an ``import/module`` :ref:`auditing event <auditing>` message) and an issue (which I created for you). This is so it's possible to see from the changelog when it was introduced, and find links back to the PR.


One or more ``import`` events may occur for the same module name. An
``import/module`` event is generated for a given module name after the
first time the module is loaded and initialized, or loading fails.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add: On failure, the value of *module* will be ``None``. (assuming that it will be None, and not something else.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants