[Python-checkins] cpython: Issue #19713: Move away from using find_module/load_module.
eric.snow
python-checkins at python.org
Sat Jan 4 23:13:52 CET 2014
http://hg.python.org/cpython/rev/a18c1a4cf30a
changeset: 88300:a18c1a4cf30a
user: Eric Snow <ericsnowcurrently at gmail.com>
date: Sat Jan 04 15:09:28 2014 -0700
summary:
Issue #19713: Move away from using find_module/load_module.
files:
Lib/test/test_tools.py | 9 +++++----
Misc/NEWS | 2 ++
setup.py | 6 +++++-
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py
--- a/Lib/test/test_tools.py
+++ b/Lib/test/test_tools.py
@@ -6,6 +6,7 @@
import os
import sys
+import importlib._bootstrap
import importlib.machinery
import unittest
from unittest import mock
@@ -405,8 +406,8 @@
@classmethod
def setUpClass(self):
path = os.path.join(scriptsdir, 'pdeps.py')
- loader = importlib.machinery.SourceFileLoader('pdeps', path)
- self.pdeps = loader.load_module()
+ spec = importlib.util.spec_from_file_location('pdeps', path)
+ self.pdeps = importlib._bootstrap._SpecMethods(spec).load()
@classmethod
def tearDownClass(self):
@@ -430,8 +431,8 @@
def setUp(self):
path = os.path.join(scriptsdir, 'gprof2html.py')
- loader = importlib.machinery.SourceFileLoader('gprof2html', path)
- self.gprof = loader.load_module()
+ spec = importlib.util.spec_from_file_location('gprof2html', path)
+ self.gprof = importlib._bootstrap._SpecMethods(spec).load()
oldargv = sys.argv
def fixup():
sys.argv = oldargv
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -255,6 +255,8 @@
- Issue #6477: Added support for pickling the types of built-in singletons
(i.e., Ellipsis, NotImplemented, None).
+- Issue #19713: Move away from using find_module/load_module.
+
- Issue #19851: Fixed a regression in reloading sub-modules.
- ssl.create_default_context() sets OP_NO_COMPRESSION to prevent CRIME.
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,8 @@
import sys, os, importlib.machinery, re, optparse
from glob import glob
+import importlib._bootstrap
+import importlib.util
import sysconfig
from distutils import log
@@ -327,8 +329,10 @@
return
loader = importlib.machinery.ExtensionFileLoader(ext.name, ext_filename)
+ spec = importlib.util.spec_from_file_location(ext.name, ext_filename,
+ loader=loader)
try:
- loader.load_module()
+ importlib._bootstrap._SpecMethods(spec).load()
except ImportError as why:
self.failed.append(ext.name)
self.announce('*** WARNING: renaming "%s" since importing it'
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list