[Python-checkins] bpo-42748: test_asdl_parser now uses exec_module instead of load_module (#23954)

isidentical webhook-mailer at python.org
Sat Dec 26 08:25:41 EST 2020


https://github.com/python/cpython/commit/0b281f94b9e5f117d774a1e4e834e797b2b21438
commit: 0b281f94b9e5f117d774a1e4e834e797b2b21438
branch: master
author: Dong-hee Na <donghee.na at python.org>
committer: isidentical <isidentical at gmail.com>
date: 2020-12-26T16:25:21+03:00
summary:

bpo-42748: test_asdl_parser now uses exec_module instead of load_module (#23954)

files:
M Lib/test/test_asdl_parser.py

diff --git a/Lib/test/test_asdl_parser.py b/Lib/test/test_asdl_parser.py
index 2c14817aae915..d2c2b51334700 100644
--- a/Lib/test/test_asdl_parser.py
+++ b/Lib/test/test_asdl_parser.py
@@ -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 @@ def setUpClass(cls):
         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')
 



More information about the Python-checkins mailing list