Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix the rest of pep-7 issues
  • Loading branch information
fried committed Sep 23, 2024
commit c7e5b85933c2ddd95ebe9ec59973af230687b32b
4 changes: 2 additions & 2 deletions Doc/c-api/contextvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ Context object management functions:
.. c:type:: PyContextEvent

Enumeration of possible context object watcher events:
- ``PY_CONTEXT_EVENT_ENTER``
- ``PY_CONTEXT_EVENT_EXIT``
- ``Py_CONTEXT_EVENT_ENTER``
- ``Py_CONTEXT_EVENT_EXIT``

.. versionadded:: 3.14

Expand Down
2 changes: 1 addition & 1 deletion Include/cpython/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ PyAPI_FUNC(int) PyContext_Enter(PyObject *);
PyAPI_FUNC(int) PyContext_Exit(PyObject *);

typedef enum {
#define Py_DEF_EVENT(op) PY_CONTEXT_EVENT_##op,
#define Py_DEF_EVENT(op) Py_CONTEXT_EVENT_##op,
PY_FOREACH_CONTEXT_EVENT(Py_DEF_EVENT)
#undef Py_DEF_EVENT
} PyContextEvent;
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_capi/test_watchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def test_enter_error(self):
self.assertEqual(
cm.unraisable.err_msg,
"Exception ignored in "
f"PY_CONTEXT_EVENT_EXIT watcher callback for {ctx!r}"
f"Py_CONTEXT_EVENT_EXIT watcher callback for {ctx!r}"
)
self.assertEqual(str(cm.unraisable.exc_value), "boom!")

Expand Down
4 changes: 2 additions & 2 deletions Modules/_testcapi/watchers.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,10 +631,10 @@ static int num_context_object_exit_events[NUM_CONTEXT_WATCHERS] = {0, 0};

static int
handle_context_watcher_event(int which_watcher, PyContextEvent event, PyContext *ctx) {
if (event == PY_CONTEXT_EVENT_ENTER) {
if (event == Py_CONTEXT_EVENT_ENTER) {
num_context_object_enter_events[which_watcher]++;
}
else if (event == PY_CONTEXT_EVENT_EXIT) {
else if (event == Py_CONTEXT_EVENT_EXIT) {
num_context_object_exit_events[which_watcher]++;
}
else {
Expand Down
8 changes: 4 additions & 4 deletions Python/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ static const char *
context_event_name(PyContextEvent event) {
switch (event) {
#define CASE(op) \
case PY_CONTEXT_EVENT_##op: \
return "PY_CONTEXT_EVENT_" #op;
Py_FOREACH_CONTEXT_EVENT(CASE)
case Py_CONTEXT_EVENT_##op: \
return "Py_CONTEXT_EVENT_" #op;
P_FOREACH_CONTEXT_EVENT(CASE)
#undef CASE
}
Py_UNREACHABLE();
Expand Down Expand Up @@ -225,7 +225,7 @@ _PyContext_Exit(PyThreadState *ts, PyObject *octx)
return -1;
}

notify_context_watchers(PY_CONTEXT_EVENT_EXIT, ctx);
notify_context_watchers(Py_CONTEXT_EVENT_EXIT, ctx);
Py_SETREF(ts->context, (PyObject *)ctx->ctx_prev);
ts->context_ver++;

Expand Down