[pypy-svn] pypy merge-stdlib: Removed references to modified-* stdlib directories.

carljm commits-noreply at bitbucket.org
Mon Mar 14 04:19:15 CET 2011


Author: Carl Meyer <carl at oddbird.net>
Branch: merge-stdlib
Changeset: r42591:dd43f492db87
Date: 2011-03-13 22:21 -0400
http://bitbucket.org/pypy/pypy/changeset/dd43f492db87/

Log:	Removed references to modified-* stdlib directories.

diff --git a/lib-python/2.7.0/test/regrtest.py b/lib-python/2.7.0/test/regrtest.py
--- a/lib-python/2.7.0/test/regrtest.py
+++ b/lib-python/2.7.0/test/regrtest.py
@@ -676,13 +676,8 @@
 
 def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
     """Return a list of all applicable test modules."""
-    if testdir:
-        testdirs = [testdir]
-    else:
-        testdirs = findtestdirs()
-    names = {}
-    for testdir in testdirs:
-        names.update(dict.fromkeys(os.listdir(testdir)))
+    testdir = findtestdir(testdir)
+    names = os.listdir(testdir)
     tests = []
     others = set(stdtests) | nottests
     for name in names:
@@ -852,6 +847,7 @@
 def runtest_inner(test, verbose, quiet,
                   testdir=None, huntrleaks=False):
     test_support.unload(test)
+    testdir = findtestdir(testdir)
     if verbose:
         capture_stdout = None
     else:
@@ -1084,19 +1080,8 @@
     # Collect cyclic trash.
     gc.collect()
 
-def findtestdirs():
-    # XXX hacking: returns a list of both the '2.7.0/test' and the
-    # 'modified-2.7.0/test' directories, as full paths.
-    testdir = os.path.abspath(os.path.dirname(__file__) or os.curdir)
-    assert os.path.basename(testdir).lower() == 'test'
-    maindir = os.path.dirname(testdir)
-    libpythondir = os.path.dirname(maindir)
-    maindirname = os.path.basename(maindir).lower()
-    if maindirname.startswith('modified-'):
-        maindirname = maindirname[len('modified-'):]
-    testdir1 = os.path.join(libpythondir, maindirname, 'test')
-    testdir2 = os.path.join(libpythondir, 'modified-'+maindirname, 'test')
-    return [testdir1, testdir2]
+def findtestdir(path=None):
+    return path or os.path.dirname(__file__) or os.curdir
 
 def removepy(names):
     if not names:
@@ -1518,7 +1503,13 @@
         return self.expected
 
 if __name__ == '__main__':
-    # Simplification for findtestdir().
+    # findtestdir() gets the dirname out of __file__, so we have to make it
+    # absolute before changing the working directory.
+    # For example __file__ may be relative when running trace or profile.
+    # See issue #9323.
+    __file__ = os.path.abspath(__file__)
+
+    # sanity check
     assert __file__ == os.path.abspath(sys.argv[0])
 
     # When tests are run from the Python build directory, it is best practice

diff --git a/pypy/tool/lib_pypy.py b/pypy/tool/lib_pypy.py
--- a/pypy/tool/lib_pypy.py
+++ b/pypy/tool/lib_pypy.py
@@ -7,7 +7,6 @@
 LIB_PYPY =  LIB_ROOT.join('lib_pypy')
 LIB_PYTHON = LIB_ROOT.join('lib-python')
 LIB_PYTHON_VANILLA = LIB_PYTHON.join('%d.%d.%d' % CPYTHON_VERSION[:3])
-LIB_PYTHON_MODIFIED = LIB_PYTHON.join('modified-%d.%d.%d' % CPYTHON_VERSION[:3])
 
 
 def import_from_lib_pypy(modname):

diff --git a/pypy/tool/pytest/confpath.py b/pypy/tool/pytest/confpath.py
--- a/pypy/tool/pytest/confpath.py
+++ b/pypy/tool/pytest/confpath.py
@@ -9,4 +9,3 @@
 assert pypydir.check(dir=1) 
 libpythondir = lib_pypy.LIB_PYTHON
 regrtestdir = lib_pypy.LIB_PYTHON_VANILLA.join('test') 
-modregrtestdir = lib_pypy.LIB_PYTHON_MODIFIED.join('test') 

diff --git a/pypy/tool/test/test_lib_pypy.py b/pypy/tool/test/test_lib_pypy.py
--- a/pypy/tool/test/test_lib_pypy.py
+++ b/pypy/tool/test/test_lib_pypy.py
@@ -8,7 +8,6 @@
 def test_lib_python_exists():
     assert lib_pypy.LIB_PYTHON.check(dir=1)
     assert lib_pypy.LIB_PYTHON_VANILLA.check(dir=1)
-    assert lib_pypy.LIB_PYTHON_MODIFIED.check(dir=1)
 
 def test_import_from_lib_pypy():
     binascii = lib_pypy.import_from_lib_pypy('binascii')

diff --git a/pypy/translator/goal/test2/test_app_main.py b/pypy/translator/goal/test2/test_app_main.py
--- a/pypy/translator/goal/test2/test_app_main.py
+++ b/pypy/translator/goal/test2/test_app_main.py
@@ -23,8 +23,8 @@
 def getscript(source):
     p = _get_next_path()
     p.write(str(py.code.Source(source)))
-    # return relative path for testing purposes 
-    return py.path.local().bestrelpath(p) 
+    # return relative path for testing purposes
+    return py.path.local().bestrelpath(p)
 
 def getscript_pyc(space, source):
     p = _get_next_path()
@@ -49,7 +49,7 @@
     pdir = _get_next_path(ext='')
     p = pdir.ensure(dir=1).join('__main__.py')
     p.write(str(py.code.Source(source)))
-    # return relative path for testing purposes 
+    # return relative path for testing purposes
     return py.path.local().bestrelpath(pdir)
 
 demo_script = getscript("""
@@ -192,7 +192,7 @@
         monkeypatch.setenv('PYTHONNOUSERSITE', '1')
         expected = {"no_user_site": True}
         self.check(['-c', 'pass'], sys_argv=['-c'], run_command='pass', **expected)
-        
+
 
 class TestInteraction:
     """
@@ -780,9 +780,9 @@
         # ------------------------------------
         # setup code for test_get_library_path
         # ------------------------------------
-        from pypy.module.sys.version import CPYTHON_VERSION, PYPY_VERSION
+        from pypy.module.sys.version import CPYTHON_VERSION
         cpy_ver = '%d.%d.%d' % CPYTHON_VERSION[:3]
-        
+
         goal_dir = os.path.dirname(app_main)
         # build a directory hierarchy like which contains both bin/pypy-c and
         # lib/pypy1.2/*
@@ -790,9 +790,8 @@
         fake_exe = prefix.join('bin/pypy-c').ensure(file=1)
         expected_path = [str(prefix.join(subdir).ensure(dir=1))
                          for subdir in ('lib_pypy',
-                                        'lib-python/modified-%s' % cpy_ver,
                                         'lib-python/%s' % cpy_ver)]
-        
+
         self.w_goal_dir = self.space.wrap(goal_dir)
         self.w_fake_exe = self.space.wrap(str(fake_exe))
         self.w_expected_path = self.space.wrap(expected_path)
@@ -822,7 +821,7 @@
             app_main.os = os
             pypy_c = os.path.join(self.trunkdir, 'pypy', 'translator', 'goal', 'pypy-c')
             newpath = app_main.get_library_path(pypy_c)
-            # we get at least lib_pypy, lib-python/modified-X.Y.Z,
+            # we get at least lib_pypy,
             # lib-python/X.Y.Z, and maybe more (e.g. plat-linux2)
             assert len(newpath) >= 3
             for p in newpath:

diff --git a/pypy/translator/sandbox/test/test_pypy_interact.py b/pypy/translator/sandbox/test/test_pypy_interact.py
--- a/pypy/translator/sandbox/test/test_pypy_interact.py
+++ b/pypy/translator/sandbox/test/test_pypy_interact.py
@@ -1,5 +1,5 @@
 import autopath
-import os, sys, stat, errno
+import os, stat, errno
 from pypy.translator.sandbox.pypy_interact import PyPySandboxedProc
 from pypy.translator.interactive import Translation
 from pypy.module.sys.version import CPYTHON_VERSION
@@ -8,7 +8,7 @@
 SITE_PY_CONTENT = open(os.path.join(autopath.pypydir,
                                     '..',
                                     'lib-python',
-                                    'modified-' + VERSION, 'site.py'),
+                                    VERSION, 'site.py'),
                        'rb').read()
 ERROR_TEXT = os.strerror(errno.ENOENT)
 
@@ -39,15 +39,15 @@
         pass
     else:
         assert_(False, "os.stat('site') should have failed")
-    st = os.stat('/bin/lib-python/modified-%s/site.py' % VERSION)
+    st = os.stat('/bin/lib-python/%s/site.py' % VERSION)
     assert_(stat.S_ISREG(st.st_mode), "bad st_mode for .../site.py")
     try:
-        os.stat('/bin/lib-python/modified-%s/site.pyc' % VERSION)
+        os.stat('/bin/lib-python/%s/site.pyc' % VERSION)
     except OSError:
         pass
     else:
         assert_(False, "os.stat('....pyc') should have failed")
-    fd = os.open('/bin/lib-python/modified-%s/site.py' % VERSION,
+    fd = os.open('/bin/lib-python/%s/site.py' % VERSION,
                  os.O_RDONLY, 0666)
     length = 8192
     ofs = 0

diff --git a/lib-python/2.7.0/site.py b/lib-python/2.7.0/site.py
--- a/lib-python/2.7.0/site.py
+++ b/lib-python/2.7.0/site.py
@@ -89,10 +89,7 @@
         if hasattr(m, '__loader__'):
             continue   # don't mess with a PEP 302-supplied __file__
         try:
-            prev = m.__file__
-            new = os.path.abspath(m.__file__)
-            if prev != new:
-                m.__file__ = new
+            m.__file__ = os.path.abspath(m.__file__)
         except (AttributeError, OSError):
             pass
 

diff --git a/pypy/module/sys/test/test_initialpath.py b/pypy/module/sys/test/test_initialpath.py
--- a/pypy/module/sys/test/test_initialpath.py
+++ b/pypy/module/sys/test/test_initialpath.py
@@ -7,9 +7,8 @@
                             CPYTHON_VERSION[1],
                             CPYTHON_VERSION[2])
     a = prefix.join('lib_pypy').ensure(dir=1)
-    b = prefix.join('lib-python', 'modified-%s' % dirname).ensure(dir=1)
-    c = prefix.join('lib-python', dirname).ensure(dir=1)
-    return a, b, c
+    b = prefix.join('lib-python', dirname).ensure(dir=1)
+    return a, b
 
 
 def test_stdlib_in_prefix(tmpdir):

diff --git a/pypy/tool/stdlib_opcode.py b/pypy/tool/stdlib_opcode.py
--- a/pypy/tool/stdlib_opcode.py
+++ b/pypy/tool/stdlib_opcode.py
@@ -106,8 +106,8 @@
     opmap as host_opmap, HAVE_ARGUMENT as host_HAVE_ARGUMENT)
 
 def load_pypy_opcode():
-    from pypy.tool.lib_pypy import LIB_PYTHON_MODIFIED
-    opcode_path = LIB_PYTHON_MODIFIED.join('opcode.py')
+    from pypy.tool.lib_pypy import LIB_PYTHON_VANILLA
+    opcode_path = LIB_PYTHON_VANILLA.join('opcode.py')
     d = {}
     execfile(str(opcode_path), d)
     for name in __all__:

diff --git a/pypy/module/sys/state.py b/pypy/module/sys/state.py
--- a/pypy/module/sys/state.py
+++ b/pypy/module/sys/state.py
@@ -2,7 +2,6 @@
 Implementation of interpreter-level 'sys' routines.
 """
 import pypy
-from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import unwrap_spec
 
 import sys, os, stat, errno
@@ -10,17 +9,17 @@
 # ____________________________________________________________
 #
 
-class State: 
-    def __init__(self, space): 
-        self.space = space 
+class State:
+    def __init__(self, space):
+        self.space = space
 
         self.w_modules = space.newdict(module=True)
 
         self.w_warnoptions = space.newlist([])
         self.w_argv = space.newlist([])
-        self.setinitialpath(space) 
+        self.setinitialpath(space)
 
-    def setinitialpath(self, space): 
+    def setinitialpath(self, space):
         # Initialize the default path
         pypydir = os.path.dirname(os.path.abspath(pypy.__file__))
         srcdir = os.path.dirname(pypydir)
@@ -43,15 +42,12 @@
     lib_python = os.path.join(prefix, 'lib-python')
     python_std_lib = os.path.join(lib_python, dirname)
     checkdir(python_std_lib)
-    python_std_lib_modified = os.path.join(lib_python, 'modified-' + dirname)
-    checkdir(python_std_lib_modified)
-    
+
     lib_pypy = os.path.join(prefix, 'lib_pypy')
     checkdir(lib_pypy)
 
     importlist = []
     importlist.append(lib_pypy)
-    importlist.append(python_std_lib_modified)
     importlist.append(python_std_lib)
     #
     # List here the extra platform-specific paths.


More information about the Pypy-commit mailing list