mirror of
https://github.com/python/cpython.git
synced 2024-11-23 09:54:58 +08:00
bee112a94d
Users want to know when the current context switches to a different context object. Right now this happens when and only when a context is entered or exited, so the enter and exit events are synonymous with "switched". However, if the changes proposed for gh-99633 are implemented, the current context will also switch for reasons other than context enter or exit. Since users actually care about context switches and not enter or exit, replace the enter and exit events with a single switched event. The former exit event was emitted just before exiting the context. The new switched event is emitted after the context is exited to match the semantics users expect of an event with a past-tense name. If users need the ability to clean up before the switch takes effect, another event type can be added in the future. It is not added here because YAGNI. I skipped 0 in the enum as a matter of practice. Skipping 0 makes it easier to troubleshoot when code forgets to set zeroed memory, and it aligns with best practices for other tools (e.g., https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum). Co-authored-by: Richard Hansen <rhansen@rhansen.org> Co-authored-by: Victor Stinner <vstinner@python.org> |
||
---|---|---|
.. | ||
clinic | ||
abstract.c | ||
buffer.c | ||
bytes.c | ||
code.c | ||
codec.c | ||
complex.c | ||
config.c | ||
datetime.c | ||
dict.c | ||
docstring.c | ||
exceptions.c | ||
file.c | ||
float.c | ||
gc.c | ||
getargs.c | ||
hash.c | ||
heaptype.c | ||
immortal.c | ||
list.c | ||
long.c | ||
mem.c | ||
monitoring.c | ||
numbers.c | ||
object.c | ||
parts.h | ||
pyatomic.c | ||
README.txt | ||
run.c | ||
set.c | ||
structmember.c | ||
time.c | ||
tuple.c | ||
unicode.c | ||
util.h | ||
vectorcall.c | ||
watchers.c |
Tests in this directory are compiled into the _testcapi extension. The main file for the extension is Modules/_testcapimodule.c, which calls `_PyTestCapi_Init_*` from these functions. General guideline when writing test code for C API. * Use Argument Clinic to minimise the amount of boilerplate code. * Add a newline between the argument spec and the docstring. * If a test description is needed, make sure the added docstring clearly and succinctly describes purpose of the function. * DRY, use the clone feature of Argument Clinic. * Try to avoid adding new interned strings; reuse existing parameter names if possible. Use the `as` feature of Argument Clinic to override the C variable name, if needed.