diff --git a/Doc/data/python3.11.abi b/Doc/data/python3.11.abi
index b0360f4121bc60..c5a1fdaea6fffc 100644
--- a/Doc/data/python3.11.abi
+++ b/Doc/data/python3.11.abi
@@ -1637,7 +1637,7 @@
-
+
@@ -1658,7 +1658,7 @@
-
+
@@ -1672,7 +1672,7 @@
-
+
@@ -1698,7 +1698,7 @@
-
+
@@ -1823,169 +1823,169 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1993,66 +1993,66 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
@@ -2062,18 +2062,18 @@
-
+
-
+
-
+
-
+
-
+
@@ -2081,23 +2081,23 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2267,19 +2267,19 @@
-
+
-
+
-
+
-
+
@@ -2295,21 +2295,21 @@
-
+
-
+
-
+
-
+
@@ -2421,11 +2421,11 @@
-
+
-
+
-
+
@@ -2461,13 +2461,13 @@
-
+
-
+
-
+
-
+
@@ -2482,14 +2482,14 @@
-
+
-
+
-
-
-
+
+
+
@@ -2543,13 +2543,13 @@
-
+
-
+
-
-
-
+
+
+
@@ -2593,15 +2593,15 @@
-
-
-
+
+
+
-
+
-
+
-
+
@@ -2641,7 +2641,7 @@
-
+
@@ -2791,18 +2791,18 @@
-
+
-
+
-
+
-
+
-
+
@@ -2849,21 +2849,21 @@
-
+
-
+
-
+
-
+
-
+
@@ -2872,12 +2872,12 @@
-
+
-
+
@@ -2890,10 +2890,10 @@
-
+
-
+
@@ -2949,18 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
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
@@ -4085,12 +4088,12 @@
-
+
-
-
+
+
@@ -4098,12 +4101,12 @@
-
+
-
-
+
+
@@ -4111,12 +4114,12 @@
-
+
-
-
+
+
@@ -4124,12 +4127,12 @@
-
+
-
-
+
+
@@ -4137,12 +4140,12 @@
-
+
-
-
+
+
@@ -4150,12 +4153,12 @@
-
+
-
-
+
+
@@ -4163,12 +4166,12 @@
-
+
-
-
+
+
@@ -4176,12 +4179,12 @@
-
+
-
-
+
+
@@ -4189,12 +4192,12 @@
-
+
-
-
+
+
@@ -4202,12 +4205,12 @@
-
+
-
-
+
+
@@ -4215,12 +4218,12 @@
-
+
-
-
+
+
@@ -4228,67 +4231,93 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
@@ -4302,36 +4331,36 @@
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
@@ -4345,10 +4374,10 @@
-
+
-
+
@@ -4359,7 +4388,7 @@
-
+
@@ -4368,17 +4397,17 @@
-
+
-
+
-
+
-
+
@@ -4396,16 +4425,16 @@
-
+
-
+
-
+
-
+
@@ -4423,7 +4452,7 @@
-
+
@@ -4435,12 +4464,12 @@
-
+
-
-
+
+
@@ -4452,11 +4481,11 @@
-
+
-
+
@@ -4515,16 +4544,16 @@
-
+
-
+
-
+
-
+
@@ -4599,7 +4628,7 @@
-
+
@@ -4647,24 +4676,24 @@
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
@@ -4681,40 +4710,40 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
@@ -4725,10 +4754,10 @@
-
+
-
+
@@ -4740,8 +4769,8 @@
-
-
+
+
@@ -4754,21 +4783,21 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
+
@@ -4782,36 +4811,36 @@
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
@@ -4822,28 +4851,28 @@
-
-
+
+
-
-
+
+
-
+
-
+
-
+
@@ -4854,13 +4883,13 @@
-
+
-
+
-
+
@@ -4883,80 +4912,80 @@
-
+
-
+
-
-
-
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -4965,37 +4994,37 @@
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
@@ -5004,7 +5033,7 @@
-
+
@@ -5030,8 +5059,8 @@
-
-
+
+
@@ -5744,10 +5773,10 @@
-
+
-
+
@@ -5759,8 +5788,8 @@
-
-
+
+
@@ -5774,44 +5803,44 @@
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -5888,9 +5917,9 @@
-
-
-
+
+
+
@@ -5901,27 +5930,27 @@
-
+
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
-
+
@@ -5930,16 +5959,16 @@
-
+
-
-
-
+
+
+
-
-
-
+
+
+
@@ -5977,10 +6006,10 @@
-
+
-
+
@@ -5989,31 +6018,31 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -6025,34 +6054,34 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
@@ -6099,9 +6128,9 @@
-
+
-
+
@@ -6120,22 +6149,22 @@
-
-
-
+
+
+
-
+
-
+
-
+
@@ -6197,7 +6226,7 @@
-
+
@@ -6232,16 +6261,16 @@
-
-
-
+
+
+
-
+
-
+
@@ -6658,10 +6687,10 @@
-
-
+
+
-
+
@@ -6671,27 +6700,27 @@
-
-
+
+
-
+
-
+
-
-
+
+
-
+
@@ -6701,23 +6730,23 @@
-
+
-
+
-
+
-
+
-
+
@@ -6772,8 +6801,8 @@
-
-
+
+
@@ -6781,31 +6810,31 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -6814,37 +6843,37 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -6875,7 +6904,7 @@
-
+
@@ -6885,7 +6914,7 @@
-
+
@@ -6905,51 +6934,51 @@
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -7002,10 +7031,10 @@
-
+
-
+
@@ -7029,7 +7058,7 @@
-
+
@@ -7044,7 +7073,7 @@
-
+
@@ -7058,10 +7087,10 @@
-
+
-
+
@@ -7074,7 +7103,7 @@
-
+
@@ -7085,7 +7114,7 @@
-
+
@@ -7093,11 +7122,11 @@
-
-
+
+
-
+
@@ -7116,7 +7145,7 @@
-
+
@@ -7130,7 +7159,7 @@
-
+
@@ -7282,7 +7311,7 @@
-
+
@@ -7294,10 +7323,10 @@
-
+
-
+
@@ -7316,7 +7345,7 @@
-
+
@@ -7335,11 +7364,11 @@
-
+
-
+
@@ -7355,7 +7384,7 @@
-
+
@@ -7397,14 +7426,14 @@
-
+
-
+
@@ -7416,27 +7445,27 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
@@ -7444,7 +7473,7 @@
-
+
@@ -7464,7 +7493,7 @@
-
+
@@ -7485,9 +7514,9 @@
-
+
-
+
@@ -7537,83 +7566,83 @@
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
@@ -7635,7 +7664,7 @@
-
+
@@ -7646,7 +7675,7 @@
-
+
@@ -7658,12 +7687,12 @@
-
-
-
+
+
+
-
+
@@ -7687,18 +7716,18 @@
-
+
-
+
-
+
@@ -7927,15 +7956,15 @@
-
+
-
+
-
+
@@ -7943,15 +7972,15 @@
-
+
-
+
-
+
@@ -7969,12 +7998,12 @@
-
+
-
+
-
+
@@ -7986,16 +8015,16 @@
-
+
-
+
-
+
-
+
@@ -8007,10 +8036,10 @@
-
+
-
+
@@ -8060,30 +8089,30 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
@@ -8101,7 +8130,7 @@
-
+
@@ -8123,7 +8152,7 @@
-
+
@@ -8164,127 +8193,127 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -8356,7 +8385,7 @@
-
+
@@ -8371,7 +8400,7 @@
-
+
@@ -8385,7 +8414,7 @@
-
+
@@ -8402,7 +8431,7 @@
-
+
@@ -8450,17 +8479,17 @@
-
+
-
+
-
+
-
+
@@ -8487,13 +8516,13 @@
-
+
-
+
-
+
-
+
@@ -8508,62 +8537,62 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
@@ -8601,7 +8630,7 @@
-
+
@@ -8632,19 +8661,19 @@
-
+
-
-
+
+
-
-
+
+
-
+
@@ -8684,11 +8713,11 @@
-
+
-
+
@@ -8708,15 +8737,15 @@
-
+
-
+
-
+
@@ -8750,7 +8779,7 @@
-
+
@@ -8761,7 +8790,7 @@
-
+
@@ -8772,7 +8801,7 @@
-
+
@@ -8787,7 +8816,7 @@
-
+
@@ -8852,13 +8881,13 @@
-
+
-
+
@@ -8902,7 +8931,7 @@
-
+
@@ -8947,11 +8976,11 @@
-
+
-
+
@@ -8972,12 +9001,12 @@
-
+
-
+
@@ -8993,7 +9022,7 @@
-
+
@@ -9003,7 +9032,7 @@
-
+
@@ -9037,7 +9066,7 @@
-
+
@@ -9056,9 +9085,9 @@
-
+
-
+
@@ -9073,7 +9102,7 @@
-
+
@@ -9085,12 +9114,12 @@
-
+
-
+
@@ -9099,9 +9128,9 @@
-
-
-
+
+
+
@@ -9109,13 +9138,13 @@
-
-
-
-
+
+
+
+
-
+
@@ -9149,22 +9178,22 @@
-
+
-
+
-
+
-
+
@@ -9177,101 +9206,101 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
@@ -9352,7 +9381,7 @@
-
+
@@ -9369,13 +9398,13 @@
-
+
-
+
@@ -9451,7 +9480,7 @@
-
+
@@ -9463,21 +9492,21 @@
-
+
-
+
-
+
-
+
@@ -9485,19 +9514,19 @@
-
+
-
+
-
+
-
+
@@ -9506,10 +9535,10 @@
-
-
+
+
-
+
@@ -9518,19 +9547,19 @@
-
+
-
+
-
+
-
+
@@ -9565,10 +9594,10 @@
-
-
+
+
-
+
@@ -9607,66 +9636,66 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
-
+
+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
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
@@ -12918,7 +12947,7 @@
-
+
@@ -12961,7 +12990,7 @@
-
+
@@ -12998,7 +13027,7 @@
-
+
@@ -13032,9 +13061,9 @@
-
-
-
+
+
+
@@ -13118,7 +13147,7 @@
-
+
@@ -13152,8 +13181,8 @@
-
-
+
+
@@ -13185,7 +13214,7 @@
-
+
@@ -13217,14 +13246,14 @@
-
+
-
+
-
+
@@ -13264,12 +13293,12 @@
-
+
-
+
@@ -13290,17 +13319,17 @@
-
+
-
-
+
+
-
+
@@ -13313,7 +13342,7 @@
-
+
@@ -13327,22 +13356,22 @@
-
-
+
+
-
-
+
+
-
+
@@ -13350,21 +13379,21 @@
-
+
-
+
-
+
@@ -13372,23 +13401,23 @@
-
-
+
+
-
-
+
+
-
+
@@ -13396,7 +13425,7 @@
-
+
@@ -13410,13 +13439,13 @@
-
+
-
+
@@ -13458,39 +13487,39 @@
-
+
-
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
@@ -13498,48 +13527,48 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
@@ -13548,78 +13577,78 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
@@ -13629,52 +13658,52 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
@@ -13791,7 +13820,7 @@
-
+
@@ -13808,7 +13837,7 @@
-
+
@@ -13825,12 +13854,12 @@
-
+
-
+
-
+
@@ -13842,159 +13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
+
+
+
-
+
@@ -14405,86 +14434,86 @@
-
+
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
@@ -14494,7 +14523,7 @@
-
+
@@ -14504,39 +14533,39 @@
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
@@ -14568,149 +14597,149 @@
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
@@ -14722,7 +14751,7 @@
-
+
@@ -14730,26 +14759,26 @@
-
+
-
+
-
+
-
+
-
+
@@ -14757,7 +14786,7 @@
-
+
@@ -14809,41 +14838,41 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
@@ -14853,7 +14882,7 @@
-
+
@@ -14864,27 +14893,27 @@
-
+
-
-
+
+
-
+
-
+
-
+
@@ -14893,7 +14922,7 @@
-
+
@@ -14901,27 +14930,27 @@
-
+
-
+
-
+
-
-
+
+
-
+
@@ -14929,7 +14958,7 @@
-
+
@@ -14937,18 +14966,18 @@
-
+
-
+
-
+
@@ -14956,7 +14985,7 @@
-
+
@@ -14980,84 +15009,84 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
@@ -15092,22 +15121,22 @@
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
@@ -15118,54 +15147,54 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -15173,135 +15202,135 @@
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
@@ -15313,16 +15342,16 @@
-
+
-
+
-
+
-
+
@@ -15335,9 +15364,9 @@
-
+
-
+
@@ -15360,7 +15389,7 @@
-
+
@@ -15378,7 +15407,7 @@
-
+
@@ -15417,18 +15446,18 @@
-
+
-
+
-
-
+
+
@@ -15436,16 +15465,16 @@
-
-
+
+
-
+
-
+
@@ -15463,7 +15492,7 @@
-
+
@@ -15472,8 +15501,8 @@
-
-
+
+
@@ -15481,65 +15510,65 @@
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
@@ -15579,21 +15608,21 @@
-
+
-
+
-
+
-
+
-
+
@@ -15603,20 +15632,20 @@
-
+
-
+
-
+
-
+
@@ -15632,11 +15661,11 @@
-
+
-
+
@@ -15647,27 +15676,27 @@
-
+
-
+
-
+
-
+
-
+
@@ -15694,7 +15723,7 @@
-
+
@@ -15714,7 +15743,7 @@
-
+
@@ -15742,7 +15771,7 @@
-
+
@@ -15764,21 +15793,21 @@
-
+
-
+
-
+
-
+
-
+
@@ -15791,77 +15820,77 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
@@ -15870,21 +15899,21 @@
-
-
+
+
-
+
-
+
-
+
-
+
@@ -15892,7 +15921,7 @@
-
+
@@ -15900,7 +15929,7 @@
-
+
@@ -15908,13 +15937,13 @@
-
+
-
+
@@ -15988,9 +16017,9 @@
-
+
-
+
@@ -16019,13 +16048,13 @@
-
+
-
+
@@ -16051,12 +16080,12 @@
-
+
-
-
-
+
+
+
@@ -16071,93 +16100,93 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
@@ -16167,36 +16196,36 @@
-
-
-
-
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
+
@@ -16210,7 +16239,7 @@
-
+
@@ -16218,95 +16247,95 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -16319,26 +16348,26 @@
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
@@ -16354,7 +16383,7 @@
-
+
@@ -16389,20 +16418,20 @@
-
+
-
+
-
+
-
+
@@ -16410,130 +16439,130 @@
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
@@ -16542,15 +16571,15 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -16558,9 +16587,9 @@
-
-
-
-
+
+
+
+
diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h
index 4e1f2ec6c3529a..cfa8ae99d1b6d9 100644
--- a/Include/internal/pycore_global_strings.h
+++ b/Include/internal/pycore_global_strings.h
@@ -201,8 +201,9 @@ struct _Py_global_strings {
STRUCT_FOR_ID(__subclasshook__)
STRUCT_FOR_ID(__truediv__)
STRUCT_FOR_ID(__trunc__)
+ STRUCT_FOR_ID(__typing_is_unpacked_typevartuple__)
STRUCT_FOR_ID(__typing_subst__)
- STRUCT_FOR_ID(__typing_unpacked__)
+ STRUCT_FOR_ID(__typing_unpacked_tuple_args__)
STRUCT_FOR_ID(__warningregistry__)
STRUCT_FOR_ID(__weakref__)
STRUCT_FOR_ID(__xor__)
diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h
index c1c5fd562e6b80..57cacb97bcf1a8 100644
--- a/Include/internal/pycore_runtime_init.h
+++ b/Include/internal/pycore_runtime_init.h
@@ -824,8 +824,9 @@ extern "C" {
INIT_ID(__subclasshook__), \
INIT_ID(__truediv__), \
INIT_ID(__trunc__), \
+ INIT_ID(__typing_is_unpacked_typevartuple__), \
INIT_ID(__typing_subst__), \
- INIT_ID(__typing_unpacked__), \
+ INIT_ID(__typing_unpacked_tuple_args__), \
INIT_ID(__warningregistry__), \
INIT_ID(__weakref__), \
INIT_ID(__xor__), \
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 6e1e8d6e1b4730..2afac235391552 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -603,22 +603,10 @@ class C(Generic[T]): pass
('generic[T]', '[int]', 'generic[int]'),
('generic[T]', '[int, str]', 'TypeError'),
('generic[T]', '[tuple_type[int, ...]]', 'generic[tuple_type[int, ...]]'),
- # Should raise TypeError: a) according to the tentative spec,
- # unpacked types cannot be used as arguments to aliases that expect
- # a fixed number of arguments; b) it's equivalent to generic[()].
- ('generic[T]', '[*tuple[()]]', 'generic[*tuple[()]]'),
- ('generic[T]', '[*Tuple[()]]', 'TypeError'),
- # Should raise TypeError according to the tentative spec: unpacked
- # types cannot be used as arguments to aliases that expect a fixed
- # number of arguments.
- ('generic[T]', '[*tuple[int]]', 'generic[*tuple[int]]'),
- ('generic[T]', '[*Tuple[int]]', 'TypeError'),
- # Ditto.
- ('generic[T]', '[*tuple[int, str]]', 'generic[*tuple[int, str]]'),
- ('generic[T]', '[*Tuple[int, str]]', 'TypeError'),
- # Ditto.
- ('generic[T]', '[*tuple[int, ...]]', 'generic[*tuple[int, ...]]'),
- ('generic[T]', '[*Tuple[int, ...]]', 'TypeError'),
+ ('generic[T]', '[*tuple_type[int]]', 'generic[int]'),
+ ('generic[T]', '[*tuple_type[()]]', 'TypeError'),
+ ('generic[T]', '[*tuple_type[int, str]]', 'TypeError'),
+ ('generic[T]', '[*tuple_type[int, ...]]', 'TypeError'),
('generic[T]', '[*Ts]', 'TypeError'),
('generic[T]', '[T, *Ts]', 'TypeError'),
('generic[T]', '[*Ts, T]', 'TypeError'),
@@ -664,23 +652,29 @@ class C(Generic[T1, T2]): pass
('generic[T1, T2]', '[int, str]', 'generic[int, str]'),
('generic[T1, T2]', '[int, str, bool]', 'TypeError'),
('generic[T1, T2]', '[*tuple_type[int]]', 'TypeError'),
- ('generic[T1, T2]', '[*tuple_type[int, str]]', 'TypeError'),
+ ('generic[T1, T2]', '[*tuple_type[int, str]]', 'generic[int, str]'),
('generic[T1, T2]', '[*tuple_type[int, str, bool]]', 'TypeError'),
- # Should raise TypeError according to the tentative spec: unpacked
- # types cannot be used as arguments to aliases that expect a fixed
- # number of arguments.
- ('generic[T1, T2]', '[*tuple[int, str], *tuple[float, bool]]', 'generic[*tuple[int, str], *tuple[float, bool]]'),
- ('generic[T1, T2]', '[*Tuple[int, str], *Tuple[float, bool]]', 'TypeError'),
+ ('generic[T1, T2]', '[int, *tuple_type[str]]', 'generic[int, str]'),
+ ('generic[T1, T2]', '[*tuple_type[int], str]', 'generic[int, str]'),
+ ('generic[T1, T2]', '[*tuple_type[int], *tuple_type[str]]', 'generic[int, str]'),
+ ('generic[T1, T2]', '[*tuple_type[int, str], *tuple_type[()]]', 'generic[int, str]'),
+ ('generic[T1, T2]', '[*tuple_type[()], *tuple_type[int, str]]', 'generic[int, str]'),
+ ('generic[T1, T2]', '[*tuple_type[int], *tuple_type[()]]', 'TypeError'),
+ ('generic[T1, T2]', '[*tuple_type[()], *tuple_type[int]]', 'TypeError'),
+ ('generic[T1, T2]', '[*tuple_type[int, str], *tuple_type[float]]', 'TypeError'),
+ ('generic[T1, T2]', '[*tuple_type[int], *tuple_type[str, float]]', 'TypeError'),
+ ('generic[T1, T2]', '[*tuple_type[int, str], *tuple_type[float, bool]]', 'TypeError'),
('generic[T1, T2]', '[tuple_type[int, ...]]', 'TypeError'),
('generic[T1, T2]', '[tuple_type[int, ...], tuple_type[str, ...]]', 'generic[tuple_type[int, ...], tuple_type[str, ...]]'),
+ # Should raise TypeError according to the tentative spec: unpacked
+ # types cannot be used as arguments to aliases that expect a fixed
+ # number of arguments.
('generic[T1, T2]', '[*tuple_type[int, ...]]', 'TypeError'),
-
- # Ditto.
- ('generic[T1, T2]', '[*tuple[int, ...], *tuple[str, ...]]', 'generic[*tuple[int, ...], *tuple[str, ...]]'),
- ('generic[T1, T2]', '[*Tuple[int, ...], *Tuple[str, ...]]', 'TypeError'),
-
+ ('generic[T1, T2]', '[int, *tuple_type[str, ...]]', 'TypeError'),
+ ('generic[T1, T2]', '[*tuple_type[int, ...], str]', 'TypeError'),
+ ('generic[T1, T2]', '[*tuple_type[int, ...], *tuple_type[str, ...]]', 'TypeError'),
('generic[T1, T2]', '[*Ts]', 'TypeError'),
('generic[T1, T2]', '[T, *Ts]', 'TypeError'),
('generic[T1, T2]', '[*Ts, T]', 'TypeError'),
@@ -720,7 +714,7 @@ class C(Generic[T1, T2, T3]): pass
tests = [
# Alias # Args # Expected result
('generic[T1, bool, T2]', '[int, str]', 'generic[int, bool, str]'),
- ('generic[T1, bool, T2]', '[*tuple_type[int, str]]', 'TypeError'),
+ ('generic[T1, bool, T2]', '[*tuple_type[int, str]]', 'generic[int, bool, str]'),
]
for alias_template, args_template, expected_template in tests:
@@ -753,96 +747,43 @@ class C(Generic[*Ts]): pass
# Tuple because tuple currently behaves differently.
tests = [
# Alias # Args # Expected result
- ('C[*Ts]', '[()]', 'C[()]'),
- ('tuple[*Ts]', '[()]', 'tuple[()]'),
- ('Tuple[*Ts]', '[()]', 'Tuple[()]'),
-
- ('C[*Ts]', '[int]', 'C[int]'),
- ('tuple[*Ts]', '[int]', 'tuple[int]'),
- ('Tuple[*Ts]', '[int]', 'Tuple[int]'),
-
- ('C[*Ts]', '[int, str]', 'C[int, str]'),
- ('tuple[*Ts]', '[int, str]', 'tuple[int, str]'),
- ('Tuple[*Ts]', '[int, str]', 'Tuple[int, str]'),
-
- ('C[*Ts]', '[*tuple_type[int]]', 'C[*tuple_type[int]]'), # Should be C[int]
- ('tuple[*Ts]', '[*tuple_type[int]]', 'tuple[*tuple_type[int]]'), # Should be tuple[int]
- ('Tuple[*Ts]', '[*tuple_type[int]]', 'Tuple[*tuple_type[int]]'), # Should be Tuple[int]
-
- ('C[*Ts]', '[*tuple_type[*Ts]]', 'C[*tuple_type[*Ts]]'), # Should be C[*Ts]
- ('tuple[*Ts]', '[*tuple_type[*Ts]]', 'tuple[*tuple_type[*Ts]]'), # Should be tuple[*Ts]
- ('Tuple[*Ts]', '[*tuple_type[*Ts]]', 'Tuple[*tuple_type[*Ts]]'), # Should be Tuple[*Ts]
-
- ('C[*Ts]', '[*tuple_type[int, str]]', 'C[*tuple_type[int, str]]'), # Should be C[int, str]
- ('tuple[*Ts]', '[*tuple_type[int, str]]', 'tuple[*tuple_type[int, str]]'), # Should be tuple[int, str]
- ('Tuple[*Ts]', '[*tuple_type[int, str]]', 'Tuple[*tuple_type[int, str]]'), # Should be Tuple[int, str]
-
- ('C[*Ts]', '[tuple_type[int, ...]]', 'C[tuple_type[int, ...]]'),
- ('tuple[*Ts]', '[tuple_type[int, ...]]', 'tuple[tuple_type[int, ...]]'),
- ('Tuple[*Ts]', '[tuple_type[int, ...]]', 'Tuple[tuple_type[int, ...]]'),
-
- ('C[*Ts]', '[tuple_type[int, ...], tuple_type[str, ...]]', 'C[tuple_type[int, ...], tuple_type[str, ...]]'),
- ('tuple[*Ts]', '[tuple_type[int, ...], tuple_type[str, ...]]', 'tuple[tuple_type[int, ...], tuple_type[str, ...]]'),
- ('Tuple[*Ts]', '[tuple_type[int, ...], tuple_type[str, ...]]', 'Tuple[tuple_type[int, ...], tuple_type[str, ...]]'),
-
- ('C[*Ts]', '[*tuple_type[int, ...]]', 'C[*tuple_type[int, ...]]'),
- ('tuple[*Ts]', '[*tuple_type[int, ...]]', 'tuple[*tuple_type[int, ...]]'),
- ('Tuple[*Ts]', '[*tuple_type[int, ...]]', 'Tuple[*tuple_type[int, ...]]'),
+ ('generic[*Ts]', '[()]', 'generic[()]'),
+ ('generic[*Ts]', '[int]', 'generic[int]'),
+ ('generic[*Ts]', '[int, str]', 'generic[int, str]'),
+ ('generic[*Ts]', '[*tuple_type[int]]', 'generic[int]'),
+ ('generic[*Ts]', '[*tuple_type[*Ts]]', 'generic[*Ts]'),
+ ('generic[*Ts]', '[*tuple_type[int, str]]', 'generic[int, str]'),
+ ('generic[*Ts]', '[tuple_type[int, ...]]', 'generic[tuple_type[int, ...]]'),
+ ('generic[*Ts]', '[tuple_type[int, ...], tuple_type[str, ...]]', 'generic[tuple_type[int, ...], tuple_type[str, ...]]'),
+ ('generic[*Ts]', '[*tuple_type[int, ...]]', 'generic[*tuple_type[int, ...]]'),
# Technically, multiple unpackings are forbidden by PEP 646, but we
# choose to be less restrictive at runtime, to allow folks room
# to experiment. So all three of these should be valid.
- ('C[*Ts]', '[*tuple_type[int, ...], *tuple_type[str, ...]]', 'C[*tuple_type[int, ...], *tuple_type[str, ...]]'),
- ('tuple[*Ts]', '[*tuple_type[int, ...], *tuple_type[str, ...]]', 'tuple[*tuple_type[int, ...], *tuple_type[str, ...]]'),
- ('Tuple[*Ts]', '[*tuple_type[int, ...], *tuple_type[str, ...]]', 'Tuple[*tuple_type[int, ...], *tuple_type[str, ...]]'),
-
- ('C[*Ts]', '[*Ts]', 'C[*Ts]'),
- ('tuple[*Ts]', '[*Ts]', 'tuple[*Ts]'),
- ('Tuple[*Ts]', '[*Ts]', 'Tuple[*Ts]'),
-
- ('C[*Ts]', '[T, *Ts]', 'C[T, *Ts]'),
- ('tuple[*Ts]', '[T, *Ts]', 'tuple[T, *Ts]'),
- ('Tuple[*Ts]', '[T, *Ts]', 'Tuple[T, *Ts]'),
+ ('generic[*Ts]', '[*tuple_type[int, ...], *tuple_type[str, ...]]', 'generic[*tuple_type[int, ...], *tuple_type[str, ...]]'),
- ('C[*Ts]', '[*Ts, T]', 'C[*Ts, T]'),
- ('tuple[*Ts]', '[*Ts, T]', 'tuple[*Ts, T]'),
- ('Tuple[*Ts]', '[*Ts, T]', 'Tuple[*Ts, T]'),
+ ('generic[*Ts]', '[*Ts]', 'generic[*Ts]'),
+ ('generic[*Ts]', '[T, *Ts]', 'generic[T, *Ts]'),
+ ('generic[*Ts]', '[*Ts, T]', 'generic[*Ts, T]'),
+ ('generic[T, *Ts]', '[int]', 'generic[int]'),
+ ('generic[T, *Ts]', '[int, str]', 'generic[int, str]'),
+ ('generic[T, *Ts]', '[int, str, bool]', 'generic[int, str, bool]'),
- ('C[T, *Ts]', '[int]', 'C[int]'),
- ('tuple[T, *Ts]', '[int]', 'tuple[int]'),
- ('Tuple[T, *Ts]', '[int]', 'Tuple[int]'),
+ ('generic[T, *Ts]', '[*tuple[int, ...]]', 'TypeError'), # Should be generic[int, *tuple[int, ...]]
- ('C[T, *Ts]', '[int, str]', 'C[int, str]'),
- ('tuple[T, *Ts]', '[int, str]', 'tuple[int, str]'),
- ('Tuple[T, *Ts]', '[int, str]', 'Tuple[int, str]'),
-
- ('C[T, *Ts]', '[int, str, bool]', 'C[int, str, bool]'),
- ('tuple[T, *Ts]', '[int, str, bool]', 'tuple[int, str, bool]'),
- ('Tuple[T, *Ts]', '[int, str, bool]', 'Tuple[int, str, bool]'),
-
- ('C[T, *Ts]', '[*tuple[int, ...]]', 'C[*tuple[int, ...]]'), # Should be C[int, *tuple[int, ...]]
- ('C[T, *Ts]', '[*Tuple[int, ...]]', 'TypeError'), # Ditto
- ('tuple[T, *Ts]', '[*tuple[int, ...]]', 'tuple[*tuple[int, ...]]'), # Should be tuple[int, *tuple[int, ...]]
- ('tuple[T, *Ts]', '[*Tuple[int, ...]]', 'TypeError'), # Should be tuple[int, *Tuple[int, ...]]
- ('Tuple[T, *Ts]', '[*tuple[int, ...]]', 'Tuple[*tuple[int, ...]]'), # Should be Tuple[int, *tuple[int, ...]]
- ('Tuple[T, *Ts]', '[*Tuple[int, ...]]', 'TypeError'), # Should be Tuple[int, *Tuple[int, ...]]
-
- ('C[*Ts, T]', '[int]', 'C[int]'),
- ('tuple[*Ts, T]', '[int]', 'tuple[int]'),
- ('Tuple[*Ts, T]', '[int]', 'Tuple[int]'),
-
- ('C[*Ts, T]', '[int, str]', 'C[int, str]'),
- ('tuple[*Ts, T]', '[int, str]', 'tuple[int, str]'),
- ('Tuple[*Ts, T]', '[int, str]', 'Tuple[int, str]'),
-
- ('C[*Ts, T]', '[int, str, bool]', 'C[int, str, bool]'),
- ('tuple[*Ts, T]', '[int, str, bool]', 'tuple[int, str, bool]'),
- ('Tuple[*Ts, T]', '[int, str, bool]', 'Tuple[int, str, bool]'),
+ ('generic[*Ts, T]', '[int]', 'generic[int]'),
+ ('generic[*Ts, T]', '[int, str]', 'generic[int, str]'),
+ ('generic[*Ts, T]', '[int, str, bool]', 'generic[int, str, bool]'),
('generic[T, *tuple_type[int, ...]]', '[str]', 'generic[str, *tuple_type[int, ...]]'),
('generic[T1, T2, *tuple_type[int, ...]]', '[str, bool]', 'generic[str, bool, *tuple_type[int, ...]]'),
('generic[T1, *tuple_type[int, ...], T2]', '[str, bool]', 'generic[str, *tuple_type[int, ...], bool]'),
('generic[T1, *tuple_type[int, ...], T2]', '[str, bool, float]', 'TypeError'),
+
+ ('generic[T1, *tuple_type[T2, ...]]', '[int, str]', 'generic[int, *tuple_type[str, ...]]'),
+ ('generic[*tuple_type[T1, ...], T2]', '[int, str]', 'generic[*tuple_type[int, ...], str]'),
+ ('generic[T1, *tuple_type[generic[*Ts], ...]]', '[int, str, bool]', 'generic[int, *tuple_type[generic[str, bool], ...]]'),
+ ('generic[*tuple_type[generic[*Ts], ...], T1]', '[int, str, bool]', 'generic[*tuple_type[generic[int, str], ...], bool]'),
]
for alias_template, args_template, expected_template in tests:
diff --git a/Lib/typing.py b/Lib/typing.py
index d655a85575811c..40ab516f7c8ff7 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -271,6 +271,16 @@ def _check_generic(cls, parameters, elen):
raise TypeError(f"Too {'many' if alen > elen else 'few'} arguments for {cls};"
f" actual {alen}, expected {elen}")
+def _unpack_args(args):
+ newargs = []
+ for arg in args:
+ subargs = getattr(arg, '__typing_unpacked_tuple_args__', None)
+ if subargs is not None and not (subargs and subargs[-1] is ...):
+ newargs.extend(subargs)
+ else:
+ newargs.append(arg)
+ return newargs
+
def _prepare_paramspec_params(cls, params):
"""Prepares the parameters for a Generic containing ParamSpec
variables (internal helper).
@@ -893,12 +903,8 @@ def __repr__(self):
def _is_unpacked_typevartuple(x: Any) -> bool:
- return (
- isinstance(x, _UnpackGenericAlias)
- # If x is Unpack[tuple[...]], __parameters__ will be empty.
- and x.__parameters__
- and isinstance(x.__parameters__[0], TypeVarTuple)
- )
+ return ((not isinstance(x, type)) and
+ getattr(x, '__typing_is_unpacked_typevartuple__', False))
def _is_typevar_like(x: Any) -> bool:
@@ -1011,7 +1017,8 @@ def __init__(self, name, *constraints, bound=None,
def __typing_subst__(self, arg):
msg = "Parameters to generic types must be types."
arg = _type_check(arg, msg, is_argument=True)
- if (isinstance(arg, _GenericAlias) and arg.__origin__ is Unpack):
+ if ((isinstance(arg, _GenericAlias) and arg.__origin__ is Unpack) or
+ (isinstance(arg, GenericAlias) and getattr(arg, '__unpacked__', False))):
raise TypeError(f"{arg} is not valid as type argument")
return arg
@@ -1370,19 +1377,17 @@ def __getitem__(self, args):
if self.__origin__ in (Generic, Protocol):
# Can't subscript Generic[...] or Protocol[...].
raise TypeError(f"Cannot subscript already-subscripted {self}")
+ if not self.__parameters__:
+ raise TypeError(f"{self} is not a generic class")
# Preprocess `args`.
if not isinstance(args, tuple):
args = (args,)
args = tuple(_type_convert(p) for p in args)
+ args = _unpack_args(args)
if (self._paramspec_tvars
and any(isinstance(t, ParamSpec) for t in self.__parameters__)):
args = _prepare_paramspec_params(self, args)
- elif not any(isinstance(p, TypeVarTuple) for p in self.__parameters__):
- # We only run this if there are no TypeVarTuples, because we
- # don't check variadic generic arity at runtime (to reduce
- # complexity of typing.py).
- _check_generic(self, args, len(self.__parameters__))
new_args = self._determine_new_args(args)
r = self.copy_with(new_args)
@@ -1406,16 +1411,28 @@ def _determine_new_args(self, args):
params = self.__parameters__
# In the example above, this would be {T3: str}
new_arg_by_param = {}
+ typevartuple_index = None
for i, param in enumerate(params):
if isinstance(param, TypeVarTuple):
- j = len(args) - (len(params) - i - 1)
- if j < i:
- raise TypeError(f"Too few arguments for {self}")
- new_arg_by_param.update(zip(params[:i], args[:i]))
- new_arg_by_param[param] = args[i: j]
- new_arg_by_param.update(zip(params[i + 1:], args[j:]))
- break
+ if typevartuple_index is not None:
+ raise TypeError(f"More than one TypeVarTuple parameter in {self}")
+ typevartuple_index = i
+
+ alen = len(args)
+ plen = len(params)
+ if typevartuple_index is not None:
+ i = typevartuple_index
+ j = alen - (plen - i - 1)
+ if j < i:
+ raise TypeError(f"Too few arguments for {self};"
+ f" actual {alen}, expected at least {plen-1}")
+ new_arg_by_param.update(zip(params[:i], args[:i]))
+ new_arg_by_param[params[i]] = tuple(args[i: j])
+ new_arg_by_param.update(zip(params[i + 1:], args[j:]))
else:
+ if alen != plen:
+ raise TypeError(f"Too {'many' if alen > plen else 'few'} arguments for {self};"
+ f" actual {alen}, expected {plen}")
new_arg_by_param.update(zip(params, args))
new_args = []
@@ -1723,14 +1740,25 @@ def __repr__(self):
return '*' + repr(self.__args__[0])
def __getitem__(self, args):
- if self.__typing_unpacked__():
+ if self.__typing_is_unpacked_typevartuple__:
return args
return super().__getitem__(args)
- def __typing_unpacked__(self):
- # If x is Unpack[tuple[...]], __parameters__ will be empty.
- return bool(self.__parameters__ and
- isinstance(self.__parameters__[0], TypeVarTuple))
+ @property
+ def __typing_unpacked_tuple_args__(self):
+ assert self.__origin__ is Unpack
+ assert len(self.__args__) == 1
+ arg, = self.__args__
+ if isinstance(arg, _GenericAlias):
+ assert arg.__origin__ is tuple
+ return arg.__args__
+ return None
+
+ @property
+ def __typing_is_unpacked_typevartuple__(self):
+ assert self.__origin__ is Unpack
+ assert len(self.__args__) == 1
+ return isinstance(self.__args__[0], TypeVarTuple)
class Generic:
diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c
index 5eeb1dbb338d22..39fd70999ecbe5 100644
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -320,20 +320,85 @@ subs_tvars(PyObject *obj, PyObject *params,
static int
_is_unpacked_typevartuple(PyObject *arg)
{
- PyObject *meth;
- int res = _PyObject_LookupAttr(arg, &_Py_ID(__typing_unpacked__), &meth);
+ PyObject *tmp;
+ if (PyType_Check(arg)) { // TODO: Add test
+ return 0;
+ }
+ int res = _PyObject_LookupAttr(arg, &_Py_ID(__typing_is_unpacked_typevartuple__), &tmp);
if (res > 0) {
- PyObject *tmp = PyObject_CallNoArgs(meth);
- Py_DECREF(meth);
- if (tmp == NULL) {
- return -1;
- }
res = PyObject_IsTrue(tmp);
Py_DECREF(tmp);
}
return res;
}
+static PyObject *
+_unpacked_tuple_args(PyObject *arg)
+{
+ PyObject *result;
+ assert(!PyType_Check(arg));
+ // Fast path
+ if (_PyGenericAlias_Check(arg) &&
+ ((gaobject *)arg)->starred &&
+ ((gaobject *)arg)->origin == (PyObject *)&PyTuple_Type)
+ {
+ result = ((gaobject *)arg)->args;
+ Py_INCREF(result);
+ return result;
+ }
+
+ if (_PyObject_LookupAttr(arg, &_Py_ID(__typing_unpacked_tuple_args__), &result) > 0) {
+ if (result == Py_None) {
+ Py_DECREF(result);
+ return NULL;
+ }
+ return result;
+ }
+ return NULL;
+}
+
+static PyObject *
+_unpack_args(PyObject *item)
+{
+ PyObject *newargs = PyList_New(0);
+ if (newargs == NULL) {
+ return NULL;
+ }
+ int is_tuple = PyTuple_Check(item);
+ Py_ssize_t nitems = is_tuple ? PyTuple_GET_SIZE(item) : 1;
+ PyObject **argitems = is_tuple ? &PyTuple_GET_ITEM(item, 0) : &item;
+ for (Py_ssize_t i = 0; i < nitems; i++) {
+ item = argitems[i];
+ if (!PyType_Check(item)) {
+ PyObject *subargs = _unpacked_tuple_args(item);
+ if (subargs != NULL &&
+ PyTuple_Check(subargs) &&
+ !(PyTuple_GET_SIZE(subargs) &&
+ PyTuple_GET_ITEM(subargs, PyTuple_GET_SIZE(subargs)-1) == Py_Ellipsis))
+ {
+ if (PyList_SetSlice(newargs, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, subargs) < 0) {
+ Py_DECREF(subargs);
+ Py_DECREF(newargs);
+ return NULL;
+ }
+ Py_DECREF(subargs);
+ continue;
+ }
+ Py_XDECREF(subargs);
+ if (PyErr_Occurred()) {
+ Py_DECREF(newargs);
+ return NULL;
+ }
+ }
+ if (PyList_Append(newargs, item) < 0) {
+ Py_DECREF(newargs);
+ return NULL;
+ }
+ }
+ Py_SETREF(newargs, PySequence_Tuple(newargs));
+ return newargs;
+}
+
PyObject *
_Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObject *item)
{
@@ -343,18 +408,26 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
"%R is not a generic class",
self);
}
+ item = _unpack_args(item);
int is_tuple = PyTuple_Check(item);
Py_ssize_t nitems = is_tuple ? PyTuple_GET_SIZE(item) : 1;
PyObject **argitems = is_tuple ? &PyTuple_GET_ITEM(item, 0) : &item;
- Py_ssize_t varparam = 0;
- for (; varparam < nparams; varparam++) {
- PyObject *param = PyTuple_GET_ITEM(parameters, varparam);
+ Py_ssize_t varparam = nparams;
+ for (Py_ssize_t i = 0; i < nparams; i++) {
+ PyObject *param = PyTuple_GET_ITEM(parameters, i);
if (Py_TYPE(param)->tp_iter) { // TypeVarTuple
- break;
+ if (varparam < nparams) {
+ Py_DECREF(item);
+ return PyErr_Format(PyExc_TypeError,
+ "More than one TypeVarTuple parameter in %S",
+ self);
+ }
+ varparam = i;
}
}
if (varparam < nparams) {
if (nitems < nparams - 1) {
+ Py_DECREF(item);
return PyErr_Format(PyExc_TypeError,
"Too few arguments for %R",
self);
@@ -362,10 +435,11 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
}
else {
if (nitems != nparams) {
+ Py_DECREF(item);
return PyErr_Format(PyExc_TypeError,
- "Too %s arguments for %R",
+ "Too %s arguments for %R; actual %zd, expected %zd",
nitems > nparams ? "many" : "few",
- self);
+ self, nitems, nparams);
}
}
/* Replace all type variables (specified by parameters)
@@ -377,6 +451,7 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
PyObject *newargs = PyTuple_New(nargs);
if (newargs == NULL) {
+ Py_DECREF(item);
return NULL;
}
for (Py_ssize_t iarg = 0, jarg = 0; iarg < nargs; iarg++) {
@@ -384,11 +459,13 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
int unpack = _is_unpacked_typevartuple(arg);
if (unpack < 0) {
Py_DECREF(newargs);
+ Py_DECREF(item);
return NULL;
}
PyObject *subst;
if (_PyObject_LookupAttr(arg, &_Py_ID(__typing_subst__), &subst) < 0) {
Py_DECREF(newargs);
+ Py_DECREF(item);
return NULL;
}
if (subst) {
@@ -397,6 +474,7 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
if (iparam == varparam) {
Py_DECREF(subst);
Py_DECREF(newargs);
+ Py_DECREF(item);
PyErr_SetString(PyExc_TypeError,
"Substitution of bare TypeVarTuple is not supported");
return NULL;
@@ -412,6 +490,7 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
}
if (arg == NULL) {
Py_DECREF(newargs);
+ Py_DECREF(item);
return NULL;
}
if (unpack) {
@@ -419,6 +498,7 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
&PyTuple_GET_ITEM(arg, 0), PyTuple_GET_SIZE(arg));
Py_DECREF(arg);
if (jarg < 0) {
+ Py_DECREF(item);
return NULL;
}
}
@@ -428,6 +508,7 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
}
}
+ Py_DECREF(item);
return newargs;
}
@@ -454,6 +535,7 @@ ga_getitem(PyObject *self, PyObject *item)
}
PyObject *res = Py_GenericAlias(alias->origin, newargs);
+ ((gaobject *)res)->starred = alias->starred;
Py_DECREF(newargs);
return res;
@@ -518,6 +600,7 @@ static const char* const attr_exceptions[] = {
"__args__",
"__unpacked__",
"__parameters__",
+ "__typing_unpacked_tuple_args__",
"__mro_entries__",
"__reduce_ex__", // needed so we don't look up object.__reduce_ex__
"__reduce__",
@@ -689,8 +772,20 @@ ga_parameters(PyObject *self, void *unused)
return alias->parameters;
}
+static PyObject *
+ga_unpacked_tuple_args(PyObject *self, void *unused)
+{
+ gaobject *alias = (gaobject *)self;
+ if (alias->starred && alias->origin == (PyObject *)&PyTuple_Type) {
+ Py_INCREF(alias->args);
+ return alias->args;
+ }
+ Py_RETURN_NONE;
+}
+
static PyGetSetDef ga_properties[] = {
{"__parameters__", ga_parameters, (setter)NULL, "Type variables in the GenericAlias.", NULL},
+ {"__typing_unpacked_tuple_args__", ga_unpacked_tuple_args, (setter)NULL, NULL},
{0}
};