Message381114
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. |
|
Date |
User |
Action |
Args |
2020-11-16 15:30:58 | Mark.Shannon | set | recipients:
+ Mark.Shannon, nedbat, pablogsal |
2020-11-16 15:30:58 | Mark.Shannon | set | messageid: <1605540658.6.0.769594046154.issue42373@roundup.psfhosted.org> |
2020-11-16 15:30:58 | Mark.Shannon | link | issue42373 messages |
2020-11-16 15:30:58 | Mark.Shannon | create | |
|