New submission from Hasan <aliy...@hotmail.com>:
1. If we try to import modules except os or sys, we will get such events. 2. If we access frame.f_locals.items() and frame.f_code.replace() inside tracefunc, function execution shows events and stops, but if access other frame.f_locals.* it begins to call and look all files in python directory import sys def tracefunc(frame, event, arg): if event == "call": print('frame.f_locals.items: ->', frame.f_locals.items()) return tracefunc sys.setprofile(tracefunc) def test_sum(x: int, y: int): return x + y test_sum(10, 20) import asyncio ------------- event: -> call frame.f_locals.items: -> dict_items([('x', 10), ('y', 20)]) event: -> return event: -> call frame.f_locals.items: -> dict_items([('name', 'asyncio'), ('import_', <built-in function __import__>)]) event: -> call frame.f_locals.items: -> dict_items([('self', <_frozen_importlib._ModuleLockManager object at 0x10ae2a3f0>), ('name', 'asyncio')]) event: -> return event: -> call frame.f_locals.items: -> dict_items([('self', <_frozen_importlib._ModuleLockManager object at 0x10ae2a3f0>)]) event: -> call frame.f_locals.items: -> dict_items([('name', 'asyncio')]) event: -> c_call event: -> c_return event: -> call frame.f_locals.items: -> Traceback (most recent call last): File "/Users/hasanaliyev/Documents/programming/github/test/debugger/notwork.py", line 38, in <module> import asyncio ^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1024, in _find_and_load File "<frozen importlib._bootstrap>", line 170, in __enter__ File "<frozen importlib._bootstrap>", line 196, in _get_module_lock File "<frozen importlib._bootstrap>", line 71, in __init__ File "/Users/hasanaliyev/Documents/programming/github/test/debugger/notwork.py", line 24, in tracefunc print('frame.f_locals.items: ->', frame.f_locals.items()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 139, in __repr__ AttributeError: '_ModuleLock' object has no attribute 'name' ---------- components: Library (Lib) messages: 398102 nosy: AliyevH priority: normal severity: normal status: open title: sys.setprofile bug versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44729> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com