From e0647faf98a33c90e170310e80adb3e6090420ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Wed, 25 Feb 2026 12:23:42 +0000 Subject: [PATCH 1/2] Fix compileall in lazy imports test data with bad syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- .../lazy_imports/{ => badsyntax}/lazy_class_body.py | 0 .../{ => badsyntax}/lazy_future_import.py | 0 .../lazy_imports/{ => badsyntax}/lazy_import_func.py | 0 .../lazy_imports/{ => badsyntax}/lazy_try_except.py | 0 .../{ => badsyntax}/lazy_try_except_from.py | 0 .../{ => badsyntax}/lazy_try_except_from_star.py | 0 Lib/test/test_import/test_lazy_imports.py | 12 ++++++------ 7 files changed, 6 insertions(+), 6 deletions(-) rename Lib/test/test_import/data/lazy_imports/{ => badsyntax}/lazy_class_body.py (100%) rename Lib/test/test_import/data/lazy_imports/{ => badsyntax}/lazy_future_import.py (100%) rename Lib/test/test_import/data/lazy_imports/{ => badsyntax}/lazy_import_func.py (100%) rename Lib/test/test_import/data/lazy_imports/{ => badsyntax}/lazy_try_except.py (100%) rename Lib/test/test_import/data/lazy_imports/{ => badsyntax}/lazy_try_except_from.py (100%) rename Lib/test/test_import/data/lazy_imports/{ => badsyntax}/lazy_try_except_from_star.py (100%) diff --git a/Lib/test/test_import/data/lazy_imports/lazy_class_body.py b/Lib/test/test_import/data/lazy_imports/badsyntax/lazy_class_body.py similarity index 100% rename from Lib/test/test_import/data/lazy_imports/lazy_class_body.py rename to Lib/test/test_import/data/lazy_imports/badsyntax/lazy_class_body.py diff --git a/Lib/test/test_import/data/lazy_imports/lazy_future_import.py b/Lib/test/test_import/data/lazy_imports/badsyntax/lazy_future_import.py similarity index 100% rename from Lib/test/test_import/data/lazy_imports/lazy_future_import.py rename to Lib/test/test_import/data/lazy_imports/badsyntax/lazy_future_import.py diff --git a/Lib/test/test_import/data/lazy_imports/lazy_import_func.py b/Lib/test/test_import/data/lazy_imports/badsyntax/lazy_import_func.py similarity index 100% rename from Lib/test/test_import/data/lazy_imports/lazy_import_func.py rename to Lib/test/test_import/data/lazy_imports/badsyntax/lazy_import_func.py diff --git a/Lib/test/test_import/data/lazy_imports/lazy_try_except.py b/Lib/test/test_import/data/lazy_imports/badsyntax/lazy_try_except.py similarity index 100% rename from Lib/test/test_import/data/lazy_imports/lazy_try_except.py rename to Lib/test/test_import/data/lazy_imports/badsyntax/lazy_try_except.py diff --git a/Lib/test/test_import/data/lazy_imports/lazy_try_except_from.py b/Lib/test/test_import/data/lazy_imports/badsyntax/lazy_try_except_from.py similarity index 100% rename from Lib/test/test_import/data/lazy_imports/lazy_try_except_from.py rename to Lib/test/test_import/data/lazy_imports/badsyntax/lazy_try_except_from.py diff --git a/Lib/test/test_import/data/lazy_imports/lazy_try_except_from_star.py b/Lib/test/test_import/data/lazy_imports/badsyntax/lazy_try_except_from_star.py similarity index 100% rename from Lib/test/test_import/data/lazy_imports/lazy_try_except_from_star.py rename to Lib/test/test_import/data/lazy_imports/badsyntax/lazy_try_except_from_star.py diff --git a/Lib/test/test_import/test_lazy_imports.py b/Lib/test/test_import/test_lazy_imports.py index 39d37f68e0b47b..f2cb26fe2a16fc 100644 --- a/Lib/test/test_import/test_lazy_imports.py +++ b/Lib/test/test_import/test_lazy_imports.py @@ -232,22 +232,22 @@ def tearDown(self): def test_lazy_try_except(self): """lazy import inside try/except should raise SyntaxError.""" with self.assertRaises(SyntaxError): - import test.test_import.data.lazy_imports.lazy_try_except + import test.test_import.data.lazy_imports.badsyntax.lazy_try_except def test_lazy_try_except_from(self): """lazy from import inside try/except should raise SyntaxError.""" with self.assertRaises(SyntaxError): - import test.test_import.data.lazy_imports.lazy_try_except_from + import test.test_import.data.lazy_imports.badsyntax.lazy_try_except_from def test_lazy_try_except_from_star(self): """lazy from import * should raise SyntaxError.""" with self.assertRaises(SyntaxError): - import test.test_import.data.lazy_imports.lazy_try_except_from_star + import test.test_import.data.lazy_imports.badsyntax.lazy_try_except_from_star def test_lazy_future_import(self): """lazy from __future__ import should raise SyntaxError.""" with self.assertRaises(SyntaxError) as cm: - import test.test_import.data.lazy_imports.lazy_future_import + import test.test_import.data.lazy_imports.badsyntax.lazy_future_import # Check we highlight 'lazy' (column offset 0, end offset 4) self.assertEqual(cm.exception.offset, 1) self.assertEqual(cm.exception.end_offset, 5) @@ -255,7 +255,7 @@ def test_lazy_future_import(self): def test_lazy_import_func(self): """lazy import inside function should raise SyntaxError.""" with self.assertRaises(SyntaxError): - import test.test_import.data.lazy_imports.lazy_import_func + import test.test_import.data.lazy_imports.badsyntax.lazy_import_func def test_lazy_import_exec_in_function(self): """lazy import via exec() inside a function should raise SyntaxError.""" @@ -1223,7 +1223,7 @@ def test_lazy_import_inside_class_raises_syntax_error(self): # PEP 810: "The soft keyword is only allowed at the global (module) level, # not inside functions, class bodies, try blocks, or import *" with self.assertRaises(SyntaxError): - import test.test_import.data.lazy_imports.lazy_class_body + import test.test_import.data.lazy_imports.badsyntax.lazy_class_body class MixedLazyEagerImportTests(unittest.TestCase): From a4f21e2340036aff7f45cdcb368838ea5d69bbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Wed, 25 Feb 2026 15:56:15 +0000 Subject: [PATCH 2/2] Add the new directory to the Makefile list of directories to install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- Makefile.pre.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.pre.in b/Makefile.pre.in index 122957dec29b6f..aba92666720d7d 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2684,6 +2684,7 @@ TESTSUBDIRS= idlelib/idle_test \ test/test_import/data/unwritable \ test/test_import/data/lazy_imports \ test/test_import/data/lazy_imports/pkg \ + test/test_import/data/lazy_imports/badsyntax \ test/test_importlib \ test/test_importlib/builtin \ test/test_importlib/extension \