Commit 520fc2a6 authored by Gary Poster's avatar Gary Poster

fix the more troublesome problems with Python 2.7. Tests still fail after...

fix the more troublesome problems with Python 2.7.  Tests still fail after these changes, but only for trivial output-ordering issues.
parent 1e8e02f2
...@@ -144,7 +144,8 @@ def _get_system_paths(executable): ...@@ -144,7 +144,8 @@ def _get_system_paths(executable):
return (stdlib, site_paths) return (stdlib, site_paths)
def _get_version_info(executable): def _get_version_info(executable):
cmd = [executable, '-Sc', 'import sys; print repr(sys.version_info)'] cmd = [executable, '-Sc',
'import sys; print(repr(tuple(x for x in sys.version_info)))']
_proc = subprocess.Popen( _proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = _proc.communicate(); stdout, stderr = _proc.communicate();
...@@ -1541,7 +1542,7 @@ def _get_module_file(executable, name): ...@@ -1541,7 +1542,7 @@ def _get_module_file(executable, name):
cmd = [executable, "-Sc", cmd = [executable, "-Sc",
"import imp; " "import imp; "
"fp, path, desc = imp.find_module(%r); " "fp, path, desc = imp.find_module(%r); "
"fp.close; " "fp.close(); "
"print path" % (name,)] "print path" % (name,)]
env = os.environ.copy() env = os.environ.copy()
# We need to make sure that PYTHONPATH, which will often be set to # We need to make sure that PYTHONPATH, which will often be set to
......
...@@ -82,17 +82,30 @@ first. ...@@ -82,17 +82,30 @@ first.
... sys.executable = %r ... sys.executable = %r
... if 'BROKEN_DASH_S' in os.environ: ... if 'BROKEN_DASH_S' in os.environ:
... class ImportHook: ... class ImportHook:
... @staticmethod ... site = None
... def find_module(fullname, path=None): ...
... @classmethod
... def find_module(klass, fullname, path=None):
... if klass.site is None and 'site' in sys.modules:
... # Pop site out of sys.modules. This will be a
... # close-enough approximation of site not being
... # loaded for our tests--it lets us provoke the
... # right errors when the fixes are absent, and
... # works well enough when the fixes are present.
... klass.site = sys.modules.pop('site')
... if fullname == 'ConfigParser': ... if fullname == 'ConfigParser':
... raise ImportError() ... raise ImportError(fullname)
... elif fullname == 'site':
... # Keep the site module from being processed twice.
... return klass
...
... @classmethod
... def load_module(klass, fullname):
... if fullname == 'site':
... return klass.site
... raise ImportError(fullname)
... ...
... sys.meta_path.append(ImportHook) ... sys.meta_path.append(ImportHook)
... sys.modules.pop('site', None) # Keeps site out of sys.modules.
... # This will be a close-enough approximation of site not being
... # loaded for our tests--it lets us provoke the right errors when
... # the fixes are absent, and works well enough when the fixes are
... # present.
... ''' % (py_path,)) ... ''' % (py_path,))
>>> sitecustomize_file.close() >>> sitecustomize_file.close()
>>> print call_py( >>> print call_py(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment