From acc682efb0f86fcdea8fd6a321442178f825dcfb Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 16 Aug 2023 10:20:11 +0300 Subject: [PATCH 1/2] gh-107909: Test explicit `object` base in PEP695 generic classes --- Lib/test/test_type_params.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index bced641a9661fd..90b80dbfb707ec 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -148,6 +148,10 @@ def test_disallowed_expressions(self): check_syntax_error(self, "def f[T: [(x := 3) for _ in range(2)]](): pass") check_syntax_error(self, "type T = [(x := 3) for _ in range(2)]") + def test_incorrect_mro_explicit_object(self): + with self.assertRaisesRegex(TypeError, "(MRO) for bases object, Generic"): + class My[X](object): ... + class TypeParamsNonlocalTest(unittest.TestCase): def test_nonlocal_disallowed_01(self): From e4092b0aa4aa61c9b29672aa60abd89bec701053 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 16 Aug 2023 10:55:02 +0300 Subject: [PATCH 2/2] Fix CI --- Lib/test/test_type_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 90b80dbfb707ec..0045057f181e1c 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -149,7 +149,7 @@ def test_disallowed_expressions(self): check_syntax_error(self, "type T = [(x := 3) for _ in range(2)]") def test_incorrect_mro_explicit_object(self): - with self.assertRaisesRegex(TypeError, "(MRO) for bases object, Generic"): + with self.assertRaisesRegex(TypeError, r"\(MRO\) for bases object, Generic"): class My[X](object): ...