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

sys._getframe audit event has frame as argument in 3.8-3.10 #91348

Closed
Dutcho mannequin opened this issue Apr 1, 2022 · 2 comments
Closed

sys._getframe audit event has frame as argument in 3.8-3.10 #91348

Dutcho mannequin opened this issue Apr 1, 2022 · 2 comments
Labels
3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes

Comments

@Dutcho
Copy link
Mannequin

Dutcho mannequin commented Apr 1, 2022

BPO 47192
Nosy @zooba, @Dutcho

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2022-04-01.18:47:06.469>
labels = ['3.8', '3.9', '3.10', '3.11']
title = 'sys._getframe audit event has frame as argument in 3.8-3.10'
updated_at = <Date 2022-04-02.13:14:53.178>
user = 'https://github.com/Dutcho'

bugs.python.org fields:

activity = <Date 2022-04-02.13:14:53.178>
actor = 'steve.dower'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2022-04-01.18:47:06.469>
creator = 'Dutcho'
dependencies = []
files = []
hgrepos = []
issue_num = 47192
keywords = []
message_count = 2.0
messages = ['416506', '416554']
nosy_count = 2.0
nosy_names = ['steve.dower', 'Dutcho']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue47192'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

@Dutcho
Copy link
Mannequin Author

Dutcho mannequin commented Apr 1, 2022

Documentation (https://docs.python.org/3/library/audit_events.html and https://docs.python.org/3/library/sys.html#sys._getframe) states that sys._getframe() "raises [...] an auditing event with no arguments".
However, Python 3.8-3.10 provide the frame as argument to the hook function. Python 3.11 behaves consistently with documentation.
But I couldn't find the change mentioned in the change log. Therefore, I'm uncertain whether that's intentional or not, so whether it'll remain in the release version.

This is demonstrated by running snippet audit.py

import sys
sys.addaudithook(print)
print(sys.version)
sys._getframe()

in various versions:

3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
sys._getframe (<frame at 0x00000209AD68C440, file 'audit.py', line 4, code <module>>,)

3.9.11 (tags/v3.9.11:2de452f, Mar 16 2022, 14:33:45) [MSC v.1929 64 bit (AMD64)]
sys._getframe (<frame at 0x00000199B7593FD0, file 'C:\\Users\\...\\audit.py', line 4, code <module>>,)

3.10.3 (tags/v3.10.3:a342a49, Mar 16 2022, 13:07:40) [MSC v.1929 64 bit (AMD64)]
sys._getframe (<frame at 0x00000210B95E9C40, file 'C:\\Users\\...\\audit.py', line 4, code <module>>,)

3.11.0a6 (main, Mar  7 2022, 16:46:19) [MSC v.1929 64 bit (AMD64)]
sys._getframe ()

@Dutcho Dutcho mannequin added 3.10 only security fixes 3.8 (EOL) end of life 3.9 only security fixes labels Apr 1, 2022
@zooba
Copy link
Member

zooba commented Apr 2, 2022

This should be fixed in the docs and also in 3.11. Now that we've shipped releases that include the frame, we should keep doing it.

If it's impossible to get a frame object in 3.11 (because it would deoptimize all the work that's been done there), it should pass None. Changing the value of the argument is fine, but changing the schema is not.

@zooba zooba added 3.11 only security fixes labels Apr 2, 2022
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
zooba added a commit to zooba/cpython that referenced this issue Jul 17, 2022
Update docs (the argument was always there, but previously undocumented)
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 17, 2022
…ythonGH-94928)

(cherry picked from commit 044a593)

Co-authored-by: Steve Dower <steve.dower@python.org>
@zooba zooba closed this as completed Jul 17, 2022
miss-islington added a commit that referenced this issue Jul 17, 2022
(cherry picked from commit 044a593)

Co-authored-by: Steve Dower <steve.dower@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes
Projects
None yet
Development

No branches or pull requests

1 participant