Skip to content

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

Closed

Description

@Dutcho
mannequin
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']

Activity

  1. Dutcho commented on Apr 1, 2022

    Dutchomannequin
    MannequinAuthor

    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 ()
    
  2. zooba commented on Apr 2, 2022

    @zooba
    Member

    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.

  3. transferred this issue fromon Apr 10, 2022
  4. added 2 commits that reference this issue on Jul 17, 2022
  5. added a commit that references this issue on Jul 17, 2022
  6. added a commit that references this issue on Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions