Repository navigation
Commit 7930780
authored
Fix reference leak when defining a Struct type (#1194)
`structmeta_collect_fields` owns `annotations`, and also `module_ns`
when a string `ClassVar` annotation is present. Both were released only
on the failure paths, so every successful struct class definition that
carries annotations retained its annotations dict, and a class carrying
a string `ClassVar` annotation additionally retained the namespace of
its module.
Release both on the success path. The regression tests use weakrefs
rather than reference counts, so they are meaningful on free-threaded
builds as well.
Fixes #1193.
---------
Co-authored-by: Tseluiko Aleksandr <[email protected]>1 parent 55f5cdd commit 7930780
2 files changed
Lines changed: 65 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6206 | 6206 | | |
6207 | 6207 | | |
6208 | 6208 | | |
| 6209 | + | |
| 6210 | + | |
6209 | 6211 | | |
6210 | 6212 | | |
6211 | 6213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
949 | 1012 | | |
950 | 1013 | | |
951 | 1014 | | |
| |||
0 commit comments