8000 gh-91051: fix segfault when using all 8 type watchers · carljm/cpython@1980789 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1980789

Browse files
committed
pythongh-91051: fix segfault when using all 8 type watchers
1 parent 50bbc56 commit 1980789

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Include/cpython/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ struct _ DF64 typeobject {
227227
vectorcallfunc tp_vectorcall;
228228

229229
/* bitset of which type-watchers care about this type */
230-
char tp_watched;
230+
unsigned char tp_watched;
231231
};
232232

233233
/* This struct is used by the specializer

Lib/test/test_capi/test_watchers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,16 @@ class C2: pass
294294
C2.hmm = "baz"
295295
self.assert_events([C1, [C2]])
296296

297+
def test_all_watchers(self):
298+
class C: pass
299+
with ExitStack() as stack:
300+
last_wid = -1
301+
while last_wid < self.TYPE_MAX_WATCHERS - 1:
302+
last_wid = stack.enter_context(self.watcher())
303+
self.watch(last_wid, C)
304+
C.foo = "bar"
305+
self.assert_events([C])
306+
297307
def test_watch_non_type(self):
298308
with self.watcher() as wid:
299309
with self.assertRaisesRegex(ValueError, r"Cannot watch non-type"):

0 commit comments

Comments
 (0)
0