]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42748: test_asdl_parser now uses exec_module instead of load_module (#23954)
authorDong-hee Na <donghee.na@python.org>
Sat, 26 Dec 2020 13:25:21 +0000 (22:25 +0900)
committerGitHub <noreply@github.com>
Sat, 26 Dec 2020 13:25:21 +0000 (16:25 +0300)
Lib/test/test_asdl_parser.py

index 2c14817aae915797aaa22206a61a6d80329d88fe..d2c2b51334700d2e8649b60afed604ebc355531a 100644 (file)
@@ -1,6 +1,7 @@
 """Tests for the asdl parser in Parser/asdl.py"""
 
 import importlib.machinery
+import importlib.util
 import os
 from os.path import dirname
 import sys
@@ -26,7 +27,10 @@ class TestAsdlParser(unittest.TestCase):
         sys.path.insert(0, parser_dir)
         loader = importlib.machinery.SourceFileLoader(
                 'asdl', os.path.join(parser_dir, 'asdl.py'))
-        cls.asdl = loader.load_module()
+        spec = importlib.util.spec_from_loader('asdl', loader)
+        module = importlib.util.module_from_spec(spec)
+        loader.exec_module(module)
+        cls.asdl = module
         cls.mod = cls.asdl.parse(os.path.join(parser_dir, 'Python.asdl'))
         cls.assertTrue(cls.asdl.check(cls.mod), 'Module validation failed')