Issue #19713: Move away from using find_module/load_module.
This commit is contained in:
parent
d749c7ae68
commit
335e14dd1a
|
@ -6,6 +6,7 @@ Tools directory of a Python checkout or tarball, such as reindent.py.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import importlib._bootstrap
|
||||||
import importlib.machinery
|
import importlib.machinery
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
@ -405,8 +406,8 @@ class PdepsTests(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
path = os.path.join(scriptsdir, 'pdeps.py')
|
path = os.path.join(scriptsdir, 'pdeps.py')
|
||||||
loader = importlib.machinery.SourceFileLoader('pdeps', path)
|
spec = importlib.util.spec_from_file_location('pdeps', path)
|
||||||
self.pdeps = loader.load_module()
|
self.pdeps = importlib._bootstrap._SpecMethods(spec).load()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(self):
|
def tearDownClass(self):
|
||||||
|
@ -430,8 +431,8 @@ class Gprof2htmlTests(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
path = os.path.join(scriptsdir, 'gprof2html.py')
|
path = os.path.join(scriptsdir, 'gprof2html.py')
|
||||||
loader = importlib.machinery.SourceFileLoader('gprof2html', path)
|
spec = importlib.util.spec_from_file_location('gprof2html', path)
|
||||||
self.gprof = loader.load_module()
|
self.gprof = importlib._bootstrap._SpecMethods(spec).load()
|
||||||
oldargv = sys.argv
|
oldargv = sys.argv
|
||||||
def fixup():
|
def fixup():
|
||||||
sys.argv = oldargv
|
sys.argv = oldargv
|
||||||
|
|
|
@ -255,6 +255,8 @@ Library
|
||||||
- Issue #6477: Added support for pickling the types of built-in singletons
|
- Issue #6477: Added support for pickling the types of built-in singletons
|
||||||
(i.e., Ellipsis, NotImplemented, None).
|
(i.e., Ellipsis, NotImplemented, None).
|
||||||
|
|
||||||
|
- Issue #19713: Move away from using find_module/load_module.
|
||||||
|
|
||||||
- Issue #19851: Fixed a regression in reloading sub-modules.
|
- Issue #19851: Fixed a regression in reloading sub-modules.
|
||||||
|
|
||||||
- ssl.create_default_context() sets OP_NO_COMPRESSION to prevent CRIME.
|
- ssl.create_default_context() sets OP_NO_COMPRESSION to prevent CRIME.
|
||||||
|
|
6
setup.py
6
setup.py
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
import sys, os, importlib.machinery, re, optparse
|
import sys, os, importlib.machinery, re, optparse
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
import importlib._bootstrap
|
||||||
|
import importlib.util
|
||||||
import sysconfig
|
import sysconfig
|
||||||
|
|
||||||
from distutils import log
|
from distutils import log
|
||||||
|
@ -327,8 +329,10 @@ class PyBuildExt(build_ext):
|
||||||
return
|
return
|
||||||
|
|
||||||
loader = importlib.machinery.ExtensionFileLoader(ext.name, ext_filename)
|
loader = importlib.machinery.ExtensionFileLoader(ext.name, ext_filename)
|
||||||
|
spec = importlib.util.spec_from_file_location(ext.name, ext_filename,
|
||||||
|
loader=loader)
|
||||||
try:
|
try:
|
||||||
loader.load_module()
|
importlib._bootstrap._SpecMethods(spec).load()
|
||||||
except ImportError as why:
|
except ImportError as why:
|
||||||
self.failed.append(ext.name)
|
self.failed.append(ext.name)
|
||||||
self.announce('*** WARNING: renaming "%s" since importing it'
|
self.announce('*** WARNING: renaming "%s" since importing it'
|
||||||
|
|
Loading…
Reference in New Issue