diff --git a/Doc/data/python3.12.abi b/Doc/data/python3.12.abi
index cdefda782b9..f4138bee406 100644
--- a/Doc/data/python3.12.abi
+++ b/Doc/data/python3.12.abi
@@ -2067,7 +2067,7 @@
-
+
@@ -2522,6 +2522,12 @@
+
+
+
+
+
+
@@ -4032,7 +4038,7 @@
-
+
@@ -5719,32 +5725,32 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -5801,7 +5807,7 @@
-
+
@@ -6264,12 +6270,12 @@
-
+
-
+
@@ -8195,14 +8201,14 @@
-
+
-
+
@@ -8286,122 +8292,122 @@
-
-
-
-
-
+
-
+
-
+
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -8813,19 +8819,19 @@
-
+
-
+
-
+
-
+
@@ -10818,7 +10824,7 @@
-
+
@@ -10889,10 +10895,10 @@
-
+
-
+
@@ -11104,175 +11110,181 @@
-
+
-
+
-
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
@@ -11284,7 +11296,7 @@
-
+
@@ -11316,7 +11328,7 @@
-
+
@@ -11325,10 +11337,10 @@
-
-
-
-
+
+
+
+
@@ -11336,8 +11348,8 @@
-
-
+
+
@@ -11390,8 +11402,8 @@
-
-
+
+
@@ -11399,9 +11411,9 @@
-
-
-
+
+
+
@@ -11409,7 +11421,7 @@
-
+
@@ -11417,8 +11429,8 @@
-
-
+
+
@@ -11450,8 +11462,8 @@
-
-
+
+
@@ -11513,16 +11525,16 @@
-
+
-
+
-
+
-
+
@@ -11600,7 +11612,7 @@
-
+
@@ -11645,8 +11657,8 @@
-
-
+
+
@@ -11657,26 +11669,26 @@
-
+
-
+
-
+
-
-
+
+
-
+
-
+
@@ -11684,7 +11696,7 @@
-
+
@@ -11708,20 +11720,20 @@
-
-
+
+
-
+
-
+
-
-
+
+
@@ -11747,48 +11759,48 @@
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
@@ -11800,8 +11812,8 @@
-
-
+
+
@@ -11809,7 +11821,7 @@
-
+
@@ -11820,7 +11832,7 @@
-
+
@@ -11841,13 +11853,13 @@
-
+
-
+
-
+
@@ -11877,10 +11889,10 @@
-
+
-
+
@@ -11904,7 +11916,7 @@
-
+
@@ -11916,10 +11928,10 @@
-
+
-
+
@@ -11945,11 +11957,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -11960,24 +11972,24 @@
-
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
@@ -11985,8 +11997,8 @@
-
-
+
+
@@ -11997,10 +12009,10 @@
-
+
-
+
@@ -12014,10 +12026,10 @@
-
-
+
+
-
+
@@ -12026,8 +12038,8 @@
-
-
+
+
@@ -12765,9 +12777,9 @@
-
+
-
+
@@ -12776,7 +12788,7 @@
-
+
@@ -12784,11 +12796,11 @@
-
+
-
-
+
+
@@ -12799,16 +12811,16 @@
-
-
+
+
-
+
-
+
-
+
@@ -12817,19 +12829,19 @@
-
-
-
-
-
+
+
+
+
+
-
+
-
+
@@ -12846,85 +12858,85 @@
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -12938,29 +12950,29 @@
-
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -12969,7 +12981,7 @@
-
+
@@ -12993,7 +13005,7 @@
-
+
@@ -13013,7 +13025,7 @@
-
+
@@ -13027,12 +13039,12 @@
-
+
-
+
@@ -13041,8 +13053,8 @@
-
-
+
+
@@ -13059,21 +13071,21 @@
-
+
-
+
-
+
-
+
-
+
@@ -13082,7 +13094,7 @@
-
+
@@ -13099,7 +13111,7 @@
-
+
@@ -13125,18 +13137,18 @@
-
+
-
+
-
+
-
+
@@ -13148,30 +13160,30 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -13223,13 +13235,13 @@
-
+
-
+
@@ -13238,23 +13250,23 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -13274,7 +13286,7 @@
-
+
@@ -13291,7 +13303,7 @@
-
+
@@ -13315,7 +13327,7 @@
-
+
@@ -13329,38 +13341,38 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -13371,22 +13383,22 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -13397,7 +13409,7 @@
-
+
@@ -13432,2438 +13444,2438 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-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
+
-
+
-
+
@@ -16047,7 +16059,7 @@
-
+
@@ -16062,16 +16074,16 @@
-
+
-
+
-
+
-
+
@@ -16080,13 +16092,13 @@
-
+
-
+
-
+
@@ -16116,7 +16128,7 @@
-
+
@@ -16140,13 +16152,13 @@
-
+
-
+
-
+
@@ -16161,58 +16173,58 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16236,16 +16248,16 @@
-
+
-
+
-
+
-
+
@@ -16259,21 +16271,21 @@
-
+
-
+
-
+
-
+
-
+
@@ -16281,68 +16293,68 @@
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
@@ -16351,17 +16363,17 @@
-
+
-
+
-
+
@@ -16385,34 +16397,34 @@
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
@@ -16421,7 +16433,7 @@
-
+
@@ -16429,42 +16441,42 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16472,22 +16484,22 @@
-
-
+
+
-
+
-
+
-
+
-
+
@@ -16498,42 +16510,42 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16541,9 +16553,9 @@
-
+
-
+
@@ -16552,8 +16564,8 @@
-
-
+
+
@@ -16570,34 +16582,34 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16606,37 +16618,37 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16645,30 +16657,30 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16680,31 +16692,31 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16716,23 +16728,23 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16740,9 +16752,9 @@
-
+
-
+
@@ -16751,7 +16763,7 @@
-
+
@@ -16765,29 +16777,29 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16796,28 +16808,28 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16828,7 +16840,7 @@
-
+
@@ -16836,7 +16848,7 @@
-
+
@@ -16852,12 +16864,12 @@
-
+
-
+
@@ -16877,13 +16889,13 @@
-
-
+
+
-
+
@@ -16892,30 +16904,30 @@
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -16929,7 +16941,7 @@
-
+
@@ -16937,18 +16949,18 @@
-
+
-
+
-
+
-
+
-
+
@@ -16962,15 +16974,15 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -16984,18 +16996,18 @@
-
-
-
-
+
+
+
+
-
+
-
+
@@ -17003,8 +17015,8 @@
-
-
+
+
@@ -17012,11 +17024,11 @@
-
-
-
+
+
+
-
+
@@ -17025,10 +17037,10 @@
-
-
+
+
-
+
@@ -17037,10 +17049,10 @@
-
-
+
+
-
+
@@ -17052,21 +17064,21 @@
-
+
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -17089,24 +17101,24 @@
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
@@ -17124,25 +17136,25 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
+
+
@@ -17150,9 +17162,9 @@
-
-
-
+
+
+
@@ -17166,36 +17178,36 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -17203,7 +17215,7 @@
-
+
@@ -17211,10 +17223,10 @@
-
+
-
+
@@ -17222,10 +17234,10 @@
-
+
-
+
@@ -17242,7 +17254,7 @@
-
+
@@ -17250,18 +17262,18 @@
-
+
-
+
-
+
-
+
-
+
@@ -17269,7 +17281,7 @@
-
+
@@ -17277,7 +17289,7 @@
-
+
@@ -17288,8 +17300,8 @@
-
-
+
+
@@ -17300,106 +17312,106 @@
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -17422,7 +17434,7 @@
-
+
@@ -17430,17 +17442,17 @@
-
+
-
+
-
+
-
+
@@ -17475,163 +17487,163 @@
-
+
-
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -17639,8 +17651,8 @@
-
-
+
+
@@ -17653,17 +17665,17 @@
-
-
+
+
-
+
-
-
+
+
@@ -17671,8 +17683,8 @@
-
-
+
+
@@ -17680,8 +17692,8 @@
-
-
+
+
@@ -17689,35 +17701,35 @@
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
@@ -17725,8 +17737,8 @@
-
-
+
+
@@ -17734,29 +17746,29 @@
-
-
+
+
-
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
+
-
+
+
@@ -17794,7 +17806,7 @@
-
+
@@ -17824,22 +17836,22 @@
-
+
-
+
-
+
-
+
-
+
@@ -17890,13 +17902,13 @@
-
+
-
+
@@ -18186,7 +18198,7 @@
-
+
@@ -18217,7 +18229,7 @@
-
+
@@ -18268,7 +18280,7 @@
-
+
@@ -18278,7 +18290,7 @@
-
+
@@ -18289,7 +18301,7 @@
-
+
@@ -18299,7 +18311,7 @@
-
+
@@ -18362,7 +18374,7 @@
-
+
@@ -18383,7 +18395,7 @@
-
+
@@ -18526,27 +18538,27 @@
-
+
-
+
-
+
-
+
@@ -18586,72 +18598,76 @@
-
+
+
+
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
@@ -18660,104 +18676,104 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
+
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
@@ -18766,43 +18782,43 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -18810,22 +18826,22 @@
-
+
-
+
-
+
-
+
@@ -18835,39 +18851,39 @@
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
@@ -18876,60 +18892,60 @@
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -18937,15 +18953,15 @@
-
-
+
+
-
+
@@ -18957,7 +18973,7 @@
-
+
@@ -18967,22 +18983,22 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
+
@@ -18996,32 +19012,32 @@
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
@@ -19029,7 +19045,7 @@
-
+
@@ -19037,189 +19053,189 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
@@ -19239,43 +19255,43 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -19290,16 +19306,16 @@
-
+
-
+
-
+
@@ -19317,22 +19333,22 @@
-
+
-
+
-
+
-
+
-
+
@@ -19371,17 +19387,17 @@
-
-
-
+
+
+
-
+
-
+
@@ -19390,7 +19406,7 @@
-
+
@@ -19410,7 +19426,7 @@
-
+
@@ -19418,25 +19434,25 @@
-
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
@@ -19452,20 +19468,20 @@
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -19473,11 +19489,11 @@
-
+
-
-
+
+
@@ -19485,11 +19501,11 @@
-
+
-
-
+
+
@@ -19497,11 +19513,11 @@
-
+
-
-
+
+
@@ -19509,11 +19525,11 @@
-
+
-
-
+
+
@@ -19543,12 +19559,12 @@
-
+
-
+
-
+
@@ -19563,42 +19579,42 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -19610,51 +19626,51 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -19662,7 +19678,7 @@
-
+
@@ -19673,15 +19689,15 @@
-
+
-
+
-
+
@@ -19689,7 +19705,7 @@
-
+
@@ -19700,7 +19716,7 @@
-
+
@@ -19708,20 +19724,20 @@
-
+
-
+
-
+
-
+
@@ -19729,7 +19745,7 @@
-
+
@@ -19737,7 +19753,7 @@
-
+
@@ -19748,7 +19764,7 @@
-
+
@@ -19759,7 +19775,7 @@
-
+
@@ -19770,12 +19786,12 @@
-
+
-
+
@@ -19783,7 +19799,7 @@
-
+
@@ -19794,7 +19810,7 @@
-
+
@@ -19805,7 +19821,7 @@
-
+
@@ -19813,7 +19829,7 @@
-
+
@@ -19821,7 +19837,7 @@
-
+
@@ -19829,7 +19845,7 @@
-
+
@@ -19840,7 +19856,7 @@
-
+
@@ -19854,7 +19870,7 @@
-
+
@@ -19877,7 +19893,7 @@
-
+
@@ -19900,7 +19916,7 @@
-
+
@@ -19920,9 +19936,9 @@
-
-
-
+
+
+
@@ -19936,23 +19952,23 @@
-
+
-
+
-
+
-
+
-
+
@@ -19960,43 +19976,43 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -20031,24 +20047,24 @@
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
@@ -20086,10 +20102,10 @@
-
+
-
+
@@ -20098,31 +20114,31 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -20134,11 +20150,11 @@
-
+
-
+
@@ -20149,11 +20165,11 @@
-
+
-
-
+
+
@@ -20176,14 +20192,14 @@
-
+
-
-
+
+
@@ -20191,10 +20207,10 @@
-
-
+
+
-
+
@@ -20203,7 +20219,7 @@
-
+
@@ -20211,13 +20227,13 @@
-
-
+
+
-
+
-
+
@@ -20232,7 +20248,7 @@
-
+
@@ -20268,7 +20284,7 @@
-
+
@@ -20283,19 +20299,19 @@
-
-
+
+
-
+
-
+
@@ -20321,14 +20337,14 @@
-
+
-
+
-
+
@@ -20373,8 +20389,8 @@
-
-
+
+
@@ -20412,7 +20428,7 @@
-
+
@@ -20442,22 +20458,22 @@
-
+
-
+
-
+
-
+
-
+
@@ -20508,13 +20524,13 @@
-
+
-
+
@@ -20529,82 +20545,82 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
@@ -20828,7 +20844,7 @@
-
+
@@ -20836,143 +20852,143 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -21003,6 +21019,11 @@
+
+
+
+
+
@@ -21072,11 +21093,6 @@
-
-
-
-
-
@@ -21102,14 +21118,14 @@
-
-
+
+
-
+
-
+
@@ -21127,9 +21143,9 @@
-
-
-
+
+
+
@@ -21224,7 +21240,7 @@
-
+
@@ -21298,7 +21314,7 @@
-
+
@@ -21406,7 +21422,7 @@
-
+
@@ -21488,7 +21504,7 @@
-
+
@@ -21564,13 +21580,13 @@
-
+
-
+
@@ -21632,44 +21648,44 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -21677,7 +21693,7 @@
-
+
@@ -21685,25 +21701,25 @@
-
+
-
+
-
+
-
+
@@ -21725,7 +21741,7 @@
-
+
@@ -21763,35 +21779,35 @@
-
+
-
-
+
+
-
+
-
-
-
+
+
+
-
+
@@ -21799,7 +21815,7 @@
-
+
@@ -21808,7 +21824,7 @@
-
+
@@ -21896,66 +21912,66 @@
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
@@ -21963,30 +21979,30 @@
-
-
+
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
-
+
+
+
-
+
@@ -22019,42 +22035,42 @@
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -22095,13 +22111,13 @@
-
+
-
+
@@ -22113,7 +22129,7 @@
-
+
@@ -22214,16 +22230,16 @@
-
+
-
+
-
+
-
+
@@ -22237,17 +22253,17 @@
-
-
+
+
-
+
-
-
+
+
@@ -22261,8 +22277,8 @@
-
-
+
+
@@ -22273,8 +22289,8 @@
-
-
+
+
@@ -22282,16 +22298,16 @@
-
+
-
+
-
-
+
+
-
+
@@ -22309,8 +22325,8 @@
-
-
+
+
@@ -22348,8 +22364,8 @@
-
-
+
+
@@ -22357,46 +22373,46 @@
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
@@ -22432,23 +22448,23 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
@@ -22458,8 +22474,8 @@
-
-
+
+
@@ -22467,16 +22483,16 @@
-
-
+
+
-
+
-
+
@@ -22494,7 +22510,7 @@
-
+
@@ -22503,7 +22519,7 @@
-
+
@@ -22526,7 +22542,7 @@
-
+
@@ -22544,7 +22560,7 @@
-
+
@@ -22595,23 +22611,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -22627,38 +22643,38 @@
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
@@ -22668,56 +22684,56 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
@@ -22726,7 +22742,7 @@
-
+
@@ -22735,35 +22751,35 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
@@ -22785,44 +22801,44 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -22911,136 +22927,136 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
@@ -23048,11 +23064,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -23097,7 +23113,7 @@
-
+
@@ -23149,23 +23165,23 @@
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
@@ -23180,7 +23196,7 @@
-
+
@@ -23254,15 +23270,15 @@
-
+
-
+
-
+
@@ -23280,7 +23296,7 @@
-
+
@@ -23297,7 +23313,7 @@
-
+
@@ -23305,15 +23321,15 @@
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
@@ -23385,9 +23401,9 @@
-
+
-
+
@@ -23399,7 +23415,7 @@
-
+
@@ -23572,8 +23588,8 @@
-
-
+
+
@@ -23585,18 +23601,18 @@
-
-
-
-
-
+
+
+
+
+
-
+
@@ -23604,54 +23620,54 @@
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
+
-
+
-
-
+
+
@@ -23659,7 +23675,7 @@
-
+
@@ -23667,8 +23683,8 @@
-
-
+
+
@@ -23678,12 +23694,12 @@
-
-
-
+
+
+
-
+
@@ -23773,7 +23789,7 @@
-
+
@@ -23851,7 +23867,7 @@
-
+
@@ -23862,16 +23878,16 @@
-
+
-
-
+
+
-
+
-
+
@@ -23886,24 +23902,24 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
@@ -23945,13 +23961,13 @@
-
+
-
-
+
+
@@ -23976,30 +23992,30 @@
-
+
-
+
-
+
-
-
+
+
-
+
-
+
@@ -24013,7 +24029,7 @@
-
+
@@ -24022,7 +24038,7 @@
-
+
@@ -24064,12 +24080,12 @@
-
+
-
+
@@ -24097,27 +24113,27 @@
-
+
-
+
-
+
-
+
-
+
@@ -24138,7 +24154,7 @@
-
+
@@ -24173,12 +24189,12 @@
-
+
-
+
@@ -24196,24 +24212,24 @@
-
+
-
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -24230,8 +24246,8 @@
-
-
+
+
@@ -24258,12 +24274,12 @@
-
+
-
+
@@ -24271,7 +24287,7 @@
-
+
@@ -24280,7 +24296,7 @@
-
+
@@ -24290,18 +24306,18 @@
-
+
-
+
-
+
-
+
@@ -24319,34 +24335,34 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
@@ -24520,7 +24536,7 @@
-
+
@@ -24552,55 +24568,55 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -24608,7 +24624,7 @@
-
+
@@ -24616,26 +24632,26 @@
-
+
-
+
-
+
-
+
-
-
+
+
-
+
@@ -24647,22 +24663,22 @@
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
+
@@ -24685,20 +24701,20 @@
-
-
+
+
-
+
-
+
-
+
-
-
+
+
@@ -24712,23 +24728,23 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
+
-
-
+
+
+
+
@@ -24763,7 +24779,7 @@
-
+
@@ -24873,17 +24889,17 @@
-
+
-
-
+
+
-
+
@@ -24902,7 +24918,7 @@
-
+
@@ -25106,7 +25122,7 @@
-
+
@@ -25146,7 +25162,7 @@
-
+
@@ -25254,7 +25270,7 @@
-
+
@@ -25263,8 +25279,8 @@
-
+
@@ -25300,24 +25316,24 @@
-
-
+
+
-
+
-
+
-
+
@@ -25333,71 +25349,71 @@
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
-
+
@@ -25405,7 +25421,7 @@
-
+
@@ -25416,6 +25432,10 @@
+
+
+
+
@@ -25460,142 +25480,142 @@
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
@@ -25863,7 +25883,7 @@
-
+
@@ -25877,16 +25897,16 @@
-
-
+
+
-
+
-
+
@@ -25924,25 +25944,25 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
-
+
+
@@ -25956,15 +25976,15 @@
-
-
-
+
+
+
-
-
-
-
+
+
+
+
@@ -25977,127 +25997,127 @@
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
@@ -26111,12 +26131,12 @@
-
-
+
+
-
-
+
+
@@ -26166,55 +26186,55 @@
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
-
-
+
+
+
@@ -26230,81 +26250,81 @@
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -26341,15 +26361,15 @@
-
+
-
+
-
+
@@ -26374,7 +26394,7 @@
-
+
@@ -26414,18 +26434,18 @@
-
+
-
+
-
+
diff --git a/Include/cpython/code.h b/Include/cpython/code.h
index 565b3942ad2..03834b20c3e 100644
--- a/Include/cpython/code.h
+++ b/Include/cpython/code.h
@@ -8,16 +8,23 @@
extern "C" {
#endif
-
+/* Count of all local monitoring events */
+#define _PY_MONITORING_LOCAL_EVENTS 10
/* Count of all "real" monitoring events (not derived from other events) */
#define _PY_MONITORING_UNGROUPED_EVENTS 15
/* Count of all monitoring events */
#define _PY_MONITORING_EVENTS 17
-/* Table of which tools are active for each monitored event. */
-typedef struct _Py_Monitors {
+/* Tables of which tools are active for each monitored event. */
+/* For 3.12 ABI compatibility this is over sized */
+typedef struct _Py_LocalMonitors {
+ /* Only _PY_MONITORING_LOCAL_EVENTS of these are used */
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
-} _Py_Monitors;
+} _Py_LocalMonitors;
+
+typedef struct _Py_GlobalMonitors {
+ uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
+} _Py_GlobalMonitors;
/* Each instruction in a code object is a fixed-width value,
* currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG
@@ -81,9 +88,9 @@ typedef struct {
*/
typedef struct {
/* Monitoring specific to this code object */
- _Py_Monitors local_monitors;
+ _Py_LocalMonitors local_monitors;
/* Monitoring that is active on this code object */
- _Py_Monitors active_monitors;
+ _Py_LocalMonitors active_monitors;
/* The tools that are to be notified for events for the matching code unit */
uint8_t *tools;
/* Information to support line events */
diff --git a/Include/internal/pycore_instruments.h b/Include/internal/pycore_instruments.h
index 56de9f87171..87f70d2dc0d 100644
--- a/Include/internal/pycore_instruments.h
+++ b/Include/internal/pycore_instruments.h
@@ -29,7 +29,7 @@ extern "C" {
#define PY_MONITORING_EVENT_STOP_ITERATION 9
#define PY_MONITORING_IS_INSTRUMENTED_EVENT(ev) \
- ((ev) <= PY_MONITORING_EVENT_STOP_ITERATION)
+ ((ev) < _PY_MONITORING_LOCAL_EVENTS)
/* Other events, mainly exceptions */
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 6109e934098..1db23145a53 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -182,7 +182,7 @@ struct _is {
struct callable_cache callable_cache;
PyCodeObject *interpreter_trampoline;
- _Py_Monitors monitors;
+ _Py_GlobalMonitors monitors;
bool f_opcode_trace_set;
bool sys_profile_initialized;
bool sys_trace_initialized;
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py
index 4c7438992f8..8665c355e7f 100644
--- a/Lib/test/test_monitoring.py
+++ b/Lib/test/test_monitoring.py
@@ -1218,9 +1218,11 @@ class TestInstallIncrementallly(MonitoringTestBase, unittest.TestCase):
self.check_events(self.func2,
recorders = recorders, must_include = self.MUST_INCLUDE_CI)
+LOCAL_RECORDERS = CallRecorder, LineRecorder, CReturnRecorder, CRaiseRecorder
+
class TestLocalEvents(MonitoringTestBase, unittest.TestCase):
- def check_events(self, func, expected, tool=TEST_TOOL, recorders=(ExceptionRecorder,)):
+ def check_events(self, func, expected, tool=TEST_TOOL, recorders=()):
try:
self.assertEqual(sys.monitoring._all_events(), {})
event_list = []
@@ -1248,7 +1250,7 @@ class TestLocalEvents(MonitoringTestBase, unittest.TestCase):
line2 = 2
line3 = 3
- self.check_events(func1, recorders = MANY_RECORDERS, expected = [
+ self.check_events(func1, recorders = LOCAL_RECORDERS, expected = [
('line', 'func1', 1),
('line', 'func1', 2),
('line', 'func1', 3)])
@@ -1260,7 +1262,7 @@ class TestLocalEvents(MonitoringTestBase, unittest.TestCase):
[].append(2)
line3 = 3
- self.check_events(func2, recorders = MANY_RECORDERS, expected = [
+ self.check_events(func2, recorders = LOCAL_RECORDERS, expected = [
('line', 'func2', 1),
('line', 'func2', 2),
('call', 'append', [2]),
@@ -1277,15 +1279,17 @@ class TestLocalEvents(MonitoringTestBase, unittest.TestCase):
line = 5
line = 6
- self.check_events(func3, recorders = MANY_RECORDERS, expected = [
+ self.check_events(func3, recorders = LOCAL_RECORDERS, expected = [
('line', 'func3', 1),
('line', 'func3', 2),
('line', 'func3', 3),
- ('raise', KeyError),
('line', 'func3', 4),
('line', 'func3', 5),
('line', 'func3', 6)])
+ def test_set_non_local_event(self):
+ with self.assertRaises(ValueError):
+ sys.monitoring.set_local_events(TEST_TOOL, just_call.__code__, E.RAISE)
def line_from_offset(code, offset):
for start, end, line in code.co_lines():
@@ -1698,3 +1702,19 @@ class TestRegressions(MonitoringTestBase, unittest.TestCase):
self.assertEqual(caught, "inner")
finally:
sys.monitoring.set_events(TEST_TOOL, 0)
+
+ def test_108390(self):
+
+ class Foo:
+ def __init__(self, set_event):
+ if set_event:
+ sys.monitoring.set_events(TEST_TOOL, E.PY_RESUME)
+
+ def make_foo_optimized_then_set_event():
+ for i in range(100):
+ Foo(i == 99)
+
+ try:
+ make_foo_optimized_then_set_event()
+ finally:
+ sys.monitoring.set_events(TEST_TOOL, 0)
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-08-13-17-18-22.gh-issue-108390.TkBccC.rst b/Misc/NEWS.d/next/Core and Builtins/2023-08-13-17-18-22.gh-issue-108390.TkBccC.rst
new file mode 100644
index 00000000000..3ed596007b5
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2023-08-13-17-18-22.gh-issue-108390.TkBccC.rst
@@ -0,0 +1,4 @@
+Raise an exception when setting a non-local event (``RAISE``, ``EXCEPTION_HANDLED``,
+etc.) in ``sys.monitoring.set_local_events``.
+
+Fixes crash when tracing in recursive calls to Python classes.
diff --git a/Python/ceval.c b/Python/ceval.c
index c6f54dd2405..fdb5b72e6c0 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2021,28 +2021,30 @@ do_monitor_exc(PyThreadState *tstate, _PyInterpreterFrame *frame,
return err;
}
-static inline int
-no_tools_for_event(PyThreadState *tstate, _PyInterpreterFrame *frame, int event)
+static inline bool
+no_tools_for_global_event(PyThreadState *tstate, int event)
{
+ return tstate->interp->monitors.tools[event] == 0;
+}
+
+static inline bool
+no_tools_for_local_event(PyThreadState *tstate, _PyInterpreterFrame *frame, int event)
+{
+ assert(event < _PY_MONITORING_LOCAL_EVENTS);
_PyCoMonitoringData *data = frame->f_code->_co_monitoring;
if (data) {
- if (data->active_monitors.tools[event] == 0) {
- return 1;
- }
+ return data->active_monitors.tools[event] == 0;
}
else {
- if (tstate->interp->monitors.tools[event] == 0) {
- return 1;
- }
+ return no_tools_for_global_event(tstate, event);
}
- return 0;
}
static void
monitor_raise(PyThreadState *tstate, _PyInterpreterFrame *frame,
_Py_CODEUNIT *instr)
{
- if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_RAISE)) {
+ if (no_tools_for_global_event(tstate, PY_MONITORING_EVENT_RAISE)) {
return;
}
do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_RAISE);
@@ -2052,7 +2054,7 @@ static void
monitor_reraise(PyThreadState *tstate, _PyInterpreterFrame *frame,
_Py_CODEUNIT *instr)
{
- if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_RERAISE)) {
+ if (no_tools_for_global_event(tstate, PY_MONITORING_EVENT_RERAISE)) {
return;
}
do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_RERAISE);
@@ -2062,7 +2064,7 @@ static int
monitor_stop_iteration(PyThreadState *tstate, _PyInterpreterFrame *frame,
_Py_CODEUNIT *instr)
{
- if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_STOP_ITERATION)) {
+ if (no_tools_for_local_event(tstate, frame, PY_MONITORING_EVENT_STOP_ITERATION)) {
return 0;
}
return do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_STOP_ITERATION);
@@ -2073,7 +2075,7 @@ monitor_unwind(PyThreadState *tstate,
_PyInterpreterFrame *frame,
_Py_CODEUNIT *instr)
{
- if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_PY_UNWIND)) {
+ if (no_tools_for_global_event(tstate, PY_MONITORING_EVENT_PY_UNWIND)) {
return;
}
do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_PY_UNWIND);
@@ -2085,7 +2087,7 @@ monitor_handled(PyThreadState *tstate,
_PyInterpreterFrame *frame,
_Py_CODEUNIT *instr, PyObject *exc)
{
- if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_EXCEPTION_HANDLED)) {
+ if (no_tools_for_global_event(tstate, PY_MONITORING_EVENT_EXCEPTION_HANDLED)) {
return 0;
}
return _Py_call_instrumentation_arg(tstate, PY_MONITORING_EVENT_EXCEPTION_HANDLED, frame, instr, exc);
@@ -2096,7 +2098,7 @@ monitor_throw(PyThreadState *tstate,
_PyInterpreterFrame *frame,
_Py_CODEUNIT *instr)
{
- if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_PY_THROW)) {
+ if (no_tools_for_global_event(tstate, PY_MONITORING_EVENT_PY_THROW)) {
return;
}
do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_PY_THROW);
diff --git a/Python/instrumentation.c b/Python/instrumentation.c
index a5b10ae63e2..f612d78c913 100644
--- a/Python/instrumentation.c
+++ b/Python/instrumentation.c
@@ -1,5 +1,6 @@
+
#include "Python.h"
#include "pycore_call.h"
#include "pycore_frame.h"
@@ -136,9 +137,9 @@ is_instrumented(int opcode)
#ifndef NDEBUG
static inline bool
-monitors_equals(_Py_Monitors a, _Py_Monitors b)
+monitors_equals(_Py_LocalMonitors a, _Py_LocalMonitors b)
{
- for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
+ for (int i = 0; i < _PY_MONITORING_LOCAL_EVENTS; i++) {
if (a.tools[i] != b.tools[i]) {
return false;
}
@@ -147,42 +148,47 @@ monitors_equals(_Py_Monitors a, _Py_Monitors b)
}
#endif
-static inline _Py_Monitors
-monitors_sub(_Py_Monitors a, _Py_Monitors b)
+static inline _Py_LocalMonitors
+monitors_sub(_Py_LocalMonitors a, _Py_LocalMonitors b)
{
- _Py_Monitors res;
- for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
+ _Py_LocalMonitors res;
+ for (int i = 0; i < _PY_MONITORING_LOCAL_EVENTS; i++) {
res.tools[i] = a.tools[i] & ~b.tools[i];
}
return res;
}
#ifndef NDEBUG
-static inline _Py_Monitors
-monitors_and(_Py_Monitors a, _Py_Monitors b)
+static inline _Py_LocalMonitors
+monitors_and(_Py_LocalMonitors a, _Py_LocalMonitors b)
{
- _Py_Monitors res;
- for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
+ _Py_LocalMonitors res;
+ for (int i = 0; i < _PY_MONITORING_LOCAL_EVENTS; i++) {
res.tools[i] = a.tools[i] & b.tools[i];
}
return res;
}
#endif
-static inline _Py_Monitors
-monitors_or(_Py_Monitors a, _Py_Monitors b)
+/* The union of the *local* events in a and b.
+ * Global events like RAISE are ignored.
+ * Used for instrumentation, as only local
+ * events get instrumented.
+ */
+static inline _Py_LocalMonitors
+local_union(_Py_GlobalMonitors a, _Py_LocalMonitors b)
{
- _Py_Monitors res;
- for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
+ _Py_LocalMonitors res;
+ for (int i = 0; i < _PY_MONITORING_LOCAL_EVENTS; i++) {
res.tools[i] = a.tools[i] | b.tools[i];
}
return res;
}
static inline bool
-monitors_are_empty(_Py_Monitors m)
+monitors_are_empty(_Py_LocalMonitors m)
{
- for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
+ for (int i = 0; i < _PY_MONITORING_LOCAL_EVENTS; i++) {
if (m.tools[i]) {
return false;
}
@@ -191,9 +197,9 @@ monitors_are_empty(_Py_Monitors m)
}
static inline bool
-multiple_tools(_Py_Monitors *m)
+multiple_tools(_Py_LocalMonitors *m)
{
- for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
+ for (int i = 0; i < _PY_MONITORING_LOCAL_EVENTS; i++) {
if (_Py_popcount32(m->tools[i]) > 1) {
return true;
}
@@ -202,7 +208,19 @@ multiple_tools(_Py_Monitors *m)
}
static inline _PyMonitoringEventSet
-get_events(_Py_Monitors *m, int tool_id)
+get_local_events(_Py_LocalMonitors *m, int tool_id)
+{
+ _PyMonitoringEventSet result = 0;
+ for (int e = 0; e < _PY_MONITORING_LOCAL_EVENTS; e++) {
+ if ((m->tools[e] >> tool_id) & 1) {
+ result |= (1 << e);
+ }
+ }
+ return result;
+}
+
+static inline _PyMonitoringEventSet
+get_events(_Py_GlobalMonitors *m, int tool_id)
{
_PyMonitoringEventSet result = 0;
for (int e = 0; e < _PY_MONITORING_UNGROUPED_EVENTS; e++) {
@@ -449,10 +467,10 @@ sanity_check_instrumentation(PyCodeObject *code)
if (data == NULL) {
return;
}
- _Py_Monitors active_monitors = PyInterpreterState_Get()->monitors;
+ _Py_GlobalMonitors active_monitors = _PyInterpreterState_GET()->monitors;
if (code->_co_monitoring) {
_Py_Monitors local_monitors = code->_co_monitoring->local_monitors;
- active_monitors = monitors_or(active_monitors, local_monitors);
+ active_monitors = local_union(active_monitors, local_monitors);
}
assert(monitors_equals(
code->_co_monitoring->active_monitors,
@@ -879,7 +897,7 @@ is_version_up_to_date(PyCodeObject *code, PyInterpreterState *interp)
static bool
instrumentation_cross_checks(PyInterpreterState *interp, PyCodeObject *code)
{
- _Py_Monitors expected = monitors_or(
+ _Py_LocalMonitors expected = local_union(
interp->monitors,
code->_co_monitoring->local_monitors);
return monitors_equals(code->_co_monitoring->active_monitors, expected);
@@ -887,26 +905,29 @@ instrumentation_cross_checks(PyInterpreterState *interp, PyCodeObject *code)
#endif
static inline uint8_t
-get_tools_for_instruction(PyCodeObject * code, int i, int event)
+get_tools_for_instruction(PyCodeObject *code, PyInterpreterState *interp, int i, int event)
{
uint8_t tools;
assert(event != PY_MONITORING_EVENT_LINE);
assert(event != PY_MONITORING_EVENT_INSTRUCTION);
- assert(instrumentation_cross_checks(PyThreadState_GET()->interp, code));
- _PyCoMonitoringData *monitoring = code->_co_monitoring;
if (event >= _PY_MONITORING_UNGROUPED_EVENTS) {
assert(event == PY_MONITORING_EVENT_C_RAISE ||
event == PY_MONITORING_EVENT_C_RETURN);
event = PY_MONITORING_EVENT_CALL;
}
- if (PY_MONITORING_IS_INSTRUMENTED_EVENT(event) && monitoring->tools) {
- tools = monitoring->tools[i];
+ if (PY_MONITORING_IS_INSTRUMENTED_EVENT(event)) {
+ CHECK(is_version_up_to_date(code, interp));
+ CHECK(instrumentation_cross_checks(interp, code));
+ if (code->_co_monitoring->tools) {
+ tools = code->_co_monitoring->tools[i];
+ }
+ else {
+ tools = code->_co_monitoring->active_monitors.tools[event];
+ }
}
else {
- tools = code->_co_monitoring->active_monitors.tools[event];
+ tools = interp->monitors.tools[event];
}
- CHECK(tools_is_subset_for_event(code, event, tools));
- CHECK((tools & code->_co_monitoring->active_monitors.tools[event]) == tools);
return tools;
}
@@ -956,11 +977,11 @@ call_instrumentation_vector(
}
assert(args[2] == NULL);
args[2] = offset_obj;
- uint8_t tools = get_tools_for_instruction(code, offset, event);
+ PyInterpreterState *interp = tstate->interp;
+ uint8_t tools = get_tools_for_instruction(code, interp, offset, event);
Py_ssize_t nargsf = nargs | PY_VECTORCALL_ARGUMENTS_OFFSET;
PyObject **callargs = &args[1];
int err = 0;
- PyInterpreterState *interp = tstate->interp;
while (tools) {
int tool = most_significant_bit(tools);
assert(tool >= 0 && tool < 8);
@@ -1397,7 +1418,7 @@ initialize_lines(PyCodeObject *code)
}
static void
-initialize_line_tools(PyCodeObject *code, _Py_Monitors *all_events)
+initialize_line_tools(PyCodeObject *code, _Py_LocalMonitors *all_events)
{
uint8_t *line_tools = code->_co_monitoring->line_tools;
assert(line_tools != NULL);
@@ -1417,8 +1438,8 @@ allocate_instrumentation_data(PyCodeObject *code)
PyErr_NoMemory();
return -1;
}
- code->_co_monitoring->local_monitors = (_Py_Monitors){ 0 };
- code->_co_monitoring->active_monitors = (_Py_Monitors){ 0 };
+ code->_co_monitoring->local_monitors = (_Py_LocalMonitors){ 0 };
+ code->_co_monitoring->active_monitors = (_Py_LocalMonitors){ 0 };
code->_co_monitoring->tools = NULL;
code->_co_monitoring->lines = NULL;
code->_co_monitoring->line_tools = NULL;
@@ -1435,7 +1456,7 @@ update_instrumentation_data(PyCodeObject *code, PyInterpreterState *interp)
if (allocate_instrumentation_data(code)) {
return -1;
}
- _Py_Monitors all_events = monitors_or(
+ _Py_LocalMonitors all_events = local_union(
interp->monitors,
code->_co_monitoring->local_monitors);
bool multitools = multiple_tools(&all_events);
@@ -1518,14 +1539,23 @@ _Py_Instrument(PyCodeObject *code, PyInterpreterState *interp)
return 0;
}
int code_len = (int)Py_SIZE(code);
+ /* code->_co_firsttraceable >= code_len indicates
+ * that no instrumentation can be inserted.
+ * Exit early to avoid creating instrumentation
+ * data for potential statically allocated code
+ * objects.
+ * See https://github.com/python/cpython/issues/108390 */
+ if (code->_co_firsttraceable >= code_len) {
+ return 0;
+ }
if (update_instrumentation_data(code, interp)) {
return -1;
}
- _Py_Monitors active_events = monitors_or(
+ _Py_LocalMonitors active_events = local_union(
interp->monitors,
code->_co_monitoring->local_monitors);
- _Py_Monitors new_events;
- _Py_Monitors removed_events;
+ _Py_LocalMonitors new_events;
+ _Py_LocalMonitors removed_events;
bool restarted = interp->last_restart_version > code->_co_instrumentation_version;
if (restarted) {
@@ -1669,10 +1699,22 @@ instrument_all_executing_code_objects(PyInterpreterState *interp) {
}
static void
-set_events(_Py_Monitors *m, int tool_id, _PyMonitoringEventSet events)
+set_events(_Py_GlobalMonitors *m, int tool_id, _PyMonitoringEventSet events)
{
assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
for (int e = 0; e < _PY_MONITORING_UNGROUPED_EVENTS; e++) {
+ uint8_t *tools = &m->tools[e];
+ int active = (events >> e) & 1;
+ *tools &= ~(1 << tool_id);
+ *tools |= (active << tool_id);
+ }
+}
+
+static void
+set_local_events(_Py_LocalMonitors *m, int tool_id, _PyMonitoringEventSet events)
+{
+ assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
+ for (int e = 0; e < _PY_MONITORING_LOCAL_EVENTS; e++) {
uint8_t *tools = &m->tools[e];
int val = (events >> e) & 1;
*tools &= ~(1 << tool_id);
@@ -1715,19 +1757,23 @@ _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEvent
{
assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
PyInterpreterState *interp = _PyInterpreterState_Get();
- assert(events < (1 << _PY_MONITORING_UNGROUPED_EVENTS));
+ assert(events < (1 << _PY_MONITORING_LOCAL_EVENTS));
+ if (code->_co_firsttraceable >= Py_SIZE(code)) {
+ PyErr_Format(PyExc_SystemError, "cannot instrument shim code object '%U'", code->co_name);
+ return -1;
+ }
if (check_tool(interp, tool_id)) {
return -1;
}
if (allocate_instrumentation_data(code)) {
return -1;
}
- _Py_Monitors *local = &code->_co_monitoring->local_monitors;
- uint32_t existing_events = get_events(local, tool_id);
+ _Py_LocalMonitors *local = &code->_co_monitoring->local_monitors;
+ uint32_t existing_events = get_local_events(local, tool_id);
if (existing_events == events) {
return 0;
}
- set_events(local, tool_id, events);
+ set_local_events(local, tool_id, events);
if (is_version_up_to_date(code, interp)) {
/* Force instrumentation update */
code->_co_instrumentation_version = UINT64_MAX;
@@ -1886,7 +1932,7 @@ monitoring_get_events_impl(PyObject *module, int tool_id)
if (check_valid_tool(tool_id)) {
return -1;
}
- _Py_Monitors *m = &_PyInterpreterState_Get()->monitors;
+ _Py_GlobalMonitors *m = &_PyInterpreterState_GET()->monitors;
_PyMonitoringEventSet event_set = get_events(m, tool_id);
return event_set;
}
@@ -1949,7 +1995,7 @@ monitoring_get_local_events_impl(PyObject *module, int tool_id,
_PyMonitoringEventSet event_set = 0;
_PyCoMonitoringData *data = ((PyCodeObject *)code)->_co_monitoring;
if (data != NULL) {
- for (int e = 0; e < _PY_MONITORING_UNGROUPED_EVENTS; e++) {
+ for (int e = 0; e < _PY_MONITORING_LOCAL_EVENTS; e++) {
if ((data->local_monitors.tools[e] >> tool_id) & 1) {
event_set |= (1 << e);
}
@@ -1983,15 +2029,16 @@ monitoring_set_local_events_impl(PyObject *module, int tool_id,
if (check_valid_tool(tool_id)) {
return NULL;
}
- if (event_set < 0 || event_set >= (1 << _PY_MONITORING_EVENTS)) {
- PyErr_Format(PyExc_ValueError, "invalid event set 0x%x", event_set);
- return NULL;
- }
if ((event_set & C_RETURN_EVENTS) && (event_set & C_CALL_EVENTS) != C_CALL_EVENTS) {
PyErr_Format(PyExc_ValueError, "cannot set C_RETURN or C_RAISE events independently");
return NULL;
}
event_set &= ~C_RETURN_EVENTS;
+ if (event_set < 0 || event_set >= (1 << _PY_MONITORING_LOCAL_EVENTS)) {
+ PyErr_Format(PyExc_ValueError, "invalid local event set 0x%x", event_set);
+ return NULL;
+ }
+
if (_PyMonitoring_SetLocalEvents((PyCodeObject*)code, tool_id, event_set)) {
return NULL;
}