Commit 6d59083
The _tkinter.tkapp and _tkinter.tktimertoken types never implemented the
garbage collector protocol, so reference cycles through an interpreter's
trace function or a timer handler's callback could not be collected.
A pending timer is kept alive by the Tcl event loop, which fires it even
after the Python token is dropped, so it is treated as a GC root (only its
callback is traversed) and collecting it never cancels a live timer. The
GC slots use a plain cast rather than the type-checking macro, since the
collector may visit a surviving object at shutdown after module clearing
has reset the global type pointers. Deallocation cancels any pending timer
so its callback cannot run on freed memory.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent c59c95f commit 6d59083
3 files changed
Lines changed: 101 additions & 13 deletions
File tree
- Lib/test/test_tkinter
- Misc/NEWS.d/next/Library
- Modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
414 | 416 | | |
415 | 417 | | |
416 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
417 | 449 | | |
418 | 450 | | |
419 | 451 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
| 639 | + | |
639 | 640 | | |
640 | 641 | | |
641 | 642 | | |
| |||
2943 | 2944 | | |
2944 | 2945 | | |
2945 | 2946 | | |
2946 | | - | |
| 2947 | + | |
| 2948 | + | |
2947 | 2949 | | |
2948 | 2950 | | |
2949 | 2951 | | |
| |||
2954 | 2956 | | |
2955 | 2957 | | |
2956 | 2958 | | |
2957 | | - | |
2958 | | - | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
2959 | 2964 | | |
2960 | | - | |
2961 | | - | |
2962 | | - | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
2963 | 2969 | | |
2964 | | - | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
2965 | 2980 | | |
2966 | | - | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
2967 | 2994 | | |
2968 | 2995 | | |
2969 | 2996 | | |
| |||
3257 | 3284 | | |
3258 | 3285 | | |
3259 | 3286 | | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
3260 | 3306 | | |
3261 | 3307 | | |
3262 | 3308 | | |
3263 | | - | |
3264 | | - | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
3265 | 3312 | | |
3266 | 3313 | | |
3267 | 3314 | | |
| |||
3280 | 3327 | | |
3281 | 3328 | | |
3282 | 3329 | | |
3283 | | - | |
3284 | | - | |
| 3330 | + | |
| 3331 | + | |
3285 | 3332 | | |
3286 | 3333 | | |
3287 | 3334 | | |
| |||
3488 | 3535 | | |
3489 | 3536 | | |
3490 | 3537 | | |
| 3538 | + | |
| 3539 | + | |
3491 | 3540 | | |
3492 | 3541 | | |
3493 | 3542 | | |
| |||
3500 | 3549 | | |
3501 | 3550 | | |
3502 | 3551 | | |
| 3552 | + | |
3503 | 3553 | | |
3504 | 3554 | | |
3505 | 3555 | | |
| |||
3547 | 3597 | | |
3548 | 3598 | | |
3549 | 3599 | | |
| 3600 | + | |
| 3601 | + | |
3550 | 3602 | | |
3551 | 3603 | | |
3552 | 3604 | | |
| |||
3559 | 3611 | | |
3560 | 3612 | | |
3561 | 3613 | | |
| 3614 | + | |
3562 | 3615 | | |
3563 | 3616 | | |
3564 | 3617 | | |
| |||
0 commit comments