Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PEP 669: for loop fires LINE multiple times for body, but only one forfor #104239

Closed
Assignees
markshannon
Labels
type-bugAn unexpected behavior, bug, or error
@nedbat

Description

@nedbat

I'm experimenting with the new monitoring interface in PEP 669. The LINE event happens multiple times for the line in the body of a for loop (as I expect), but the for statement itself only gets an event on entering, not each time around the loop.

This code:

importsysdefloop3():foriinrange(3):print(i)print("done")the_code=loop3.__code__defline_callback(code,line_number):assertcode==the_codeprint(f"LINE:{line_number}")my_id=sys.monitoring.COVERAGE_IDsys.monitoring.use_tool_id(my_id,"repro")sys.monitoring.register_callback(my_id,sys.monitoring.events.LINE,line_callback)sys.monitoring.set_local_events(my_id,the_code,sys.monitoring.events.LINE)loop3()

produces:

LINE: 4LINE: 50LINE: 51LINE: 52LINE: 6done

I would expect Line 4 to be monitored after each "LINE: 5", including after the last one.

This is with commit263abd3 of CPython.

Metadata

Metadata

Assignees

Labels

type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp