This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Mark.Shannon
Recipients Mark.Shannon, nedbat, pablogsal
Date 2020-11-16.15:30:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605540658.6.0.769594046154.issue42373@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-11-16 15:30:58Mark.Shannonsetrecipients: + Mark.Shannon, nedbat, pablogsal
2020-11-16 15:30:58Mark.Shannonsetmessageid: <1605540658.6.0.769594046154.issue42373@roundup.psfhosted.org>
2020-11-16 15:30:58Mark.Shannonlinkissue42373 messages
2020-11-16 15:30:58Mark.Shannoncreate