summaryrefslogtreecommitdiff
path: root/Include/cpython/code.h
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2023-03-07 17:10:58 -0700
committerGitHub <noreply@github.com>2023-03-07 17:10:58 -0700
commit1e703a473343ed198c9a06a876b25d7d69d4bbd0 (patch)
tree0ca3e31d0953a8ec475a159e19b5570e104eeefa /Include/cpython/code.h
parenta33ca2ad1fcf857817cba505a788e15cf9d6ed0c (diff)
downloadcpython-git-1e703a473343ed198c9a06a876b25d7d69d4bbd0.tar.gz
gh-102381: don't call watcher callback with dead object (#102382)
Co-authored-by: T. Wouters <thomas@python.org>
Diffstat (limited to 'Include/cpython/code.h')
-rw-r--r--Include/cpython/code.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/Include/cpython/code.h b/Include/cpython/code.h
index 0e4bd8a58c..abcf125060 100644
--- a/Include/cpython/code.h
+++ b/Include/cpython/code.h
@@ -224,9 +224,14 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
PyAPI_FUNC(int) PyCode_Addr2Location(PyCodeObject *, int, int *, int *, int *, int *);
-typedef enum PyCodeEvent {
- PY_CODE_EVENT_CREATE,
- PY_CODE_EVENT_DESTROY
+#define PY_FOREACH_CODE_EVENT(V) \
+ V(CREATE) \
+ V(DESTROY)
+
+typedef enum {
+ #define PY_DEF_EVENT(op) PY_CODE_EVENT_##op,
+ PY_FOREACH_CODE_EVENT(PY_DEF_EVENT)
+ #undef PY_DEF_EVENT
} PyCodeEvent;
@@ -236,7 +241,7 @@ typedef enum PyCodeEvent {
* The callback is invoked with a borrowed reference to co, after it is
* created and before it is destroyed.
*
- * If the callback returns with an exception set, it must return -1. Otherwise
+ * If the callback sets an exception, it must return -1. Otherwise
* it should return 0.
*/
typedef int (*PyCode_WatchCallback)(