Skip to content

Commit 239981c

Browse files
committed
use PY_ prefix, add Py_UNREACHABLE() to switches
1 parent 33dda2a commit 239981c

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

Include/cpython/code.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,13 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
224224

225225
PyAPI_FUNC(int) PyCode_Addr2Location(PyCodeObject *, int, int *, int *, int *, int *);
226226

227-
#define FOREACH_CODE_EVENT(V) \
227+
#define PY_FOREACH_CODE_EVENT(V) \
228228
V(CREATE) \
229229
V(DESTROY)
230230

231231
typedef enum {
232232
#define DEF_EVENT(op) PY_CODE_EVENT_##op,
233-
FOREACH_CODE_EVENT(DEF_EVENT)
233+
PY_FOREACH_CODE_EVENT(DEF_EVENT)
234234
#undef DEF_EVENT
235235
} PyCodeEvent;
236236

Include/cpython/dictobject.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
9090

9191
/* Dictionary watchers */
9292

93-
#define FOREACH_DICT_EVENT(V) \
94-
V(ADDED) \
95-
V(MODIFIED) \
96-
V(DELETED) \
97-
V(CLONED) \
98-
V(CLEARED) \
93+
#define PY_FOREACH_DICT_EVENT(V) \
94+
V(ADDED) \
95+
V(MODIFIED) \
96+
V(DELETED) \
97+
V(CLONED) \
98+
V(CLEARED) \
9999
V(DEALLOCATED)
100100

101101
typedef enum {
102102
#define DEF_EVENT(EVENT) PyDict_EVENT_##EVENT,
103-
FOREACH_DICT_EVENT(DEF_EVENT)
103+
PY_FOREACH_DICT_EVENT(DEF_EVENT)
104104
#undef DEF_EVENT
105105
} PyDict_WatchEvent;
106106

Include/cpython/funcobject.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,16 @@ PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
131131
PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
132132
PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
133133

134-
#define FOREACH_FUNC_EVENT(V) \
135-
V(CREATE) \
136-
V(DESTROY) \
137-
V(MODIFY_CODE) \
138-
V(MODIFY_DEFAULTS) \
134+
#define PY_FOREACH_FUNC_EVENT(V) \
135+
V(CREATE) \
136+
V(DESTROY) \
137+
V(MODIFY_CODE) \
138+
V(MODIFY_DEFAULTS) \
139139
V(MODIFY_KWDEFAULTS)
140140

141141
typedef enum {
142142
#define DEF_EVENT(EVENT) PyFunction_EVENT_##EVENT,
143-
FOREACH_FUNC_EVENT(DEF_EVENT)
143+
PY_FOREACH_FUNC_EVENT(DEF_EVENT)
144144
#undef DEF_EVENT
145145
} PyFunction_WatchEvent;
146146

Modules/_testcapi/watchers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ _PyTestCapi_Init_Watchers(PyObject *mod)
683683
PyFunction_EVENT_##event)) { \
684684
return -1; \
685685
}
686-
FOREACH_FUNC_EVENT(ADD_EVENT);
686+
PY_FOREACH_FUNC_EVENT(ADD_EVENT);
687687
#undef ADD_EVENT
688688

689689
return 0;

Objects/codeobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ code_event_name(PyCodeEvent event) {
1919
#define CASE(op) \
2020
case PY_CODE_EVENT_##op: \
2121
return "PY_CODE_EVENT_" #op;
22-
FOREACH_CODE_EVENT(CASE)
22+
PY_FOREACH_CODE_EVENT(CASE)
2323
#undef CASE
2424
}
25+
Py_UNREACHABLE();
2526
}
2627

2728
static void

Objects/dictobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5745,9 +5745,10 @@ dict_event_name(PyDict_WatchEvent event) {
57455745
#define CASE(op) \
57465746
case PyDict_EVENT_##op: \
57475747
return "PyDict_EVENT_" #op;
5748-
FOREACH_DICT_EVENT(CASE)
5748+
PY_FOREACH_DICT_EVENT(CASE)
57495749
#undef CASE
57505750
}
5751+
Py_UNREACHABLE();
57515752
}
57525753

57535754
void

Objects/funcobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ func_event_name(PyFunction_WatchEvent event) {
1616
#define CASE(op) \
1717
case PyFunction_EVENT_##op: \
1818
return "PyFunction_EVENT_" #op;
19-
FOREACH_FUNC_EVENT(CASE)
19+
PY_FOREACH_FUNC_EVENT(CASE)
2020
#undef CASE
2121
}
22+
Py_UNREACHABLE();
2223
}
2324

2425
static void

0 commit comments

Comments
 (0)