New submission from Mark Shannon <m...@hotpy.org>:
PEP 626 doesn't cover which keywords are to be traced if they occur on a line by themselves. Some keywords, like `break`, in Python have behavior associated with them. Others, like `else` are just syntax and don't do anything. Currently, it is not clear which keywords get traced and which do not. I'd like to update the PEP to include the following: Keywords can be broken down into five groups. 1. Must have an attendant expression ( "if", "while", "for", "await") These keywords are not traced, since their expressions are. 2. Have an optional expression and perform non-local control flow ( "return", "yield", "raise", "except" ) These keywords are traced. If on a different line from the expression, they will generate additional events. 3. Pure syntax ( "else", "try", "finally" ) These keywords are not traced. 4. Local control flow ( "break", continue", "pass" ) These keywords are traced 5. Expressions ( "None", "True", "False" ) Treated like other expressions Examples: 1. if ( 2. test 3. ): will generate an event for line 2. 1. return ( 2. x 3. ): will generate an event for line 2, then line 1. 1. try: 2. None 3. finally: 4. pass Will generate an event for line 2, then line 4. Note that whatever changes, the invariant remains that if a line is in `co_lines()` then it will generate trace events, and if it isn't then it won't. ---------- assignee: Mark.Shannon messages: 381114 nosy: Mark.Shannon, nedbat, pablogsal priority: normal severity: normal status: open title: PEP 626 does not specify behavior of tracing for keywords. versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42373> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com