[issue44729] sys.setprofile bug

2021-07-23 Thread Hasan


Change by Hasan :


--
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44729] sys.setprofile bug

2021-07-23 Thread Hasan


New submission from Hasan :

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_', )])
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 
import asyncio
^^
  File "", line 1024, in _find_and_load
  File "", line 170, in __enter__
  File "", line 196, in _get_module_lock
  File "", 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 "", 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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com