[pypy-svn] r77049 - in pypy/branch/fast-forward/lib-python: . modified-2.7.0 modified-2.7.0/test

afa at codespeak.net afa at codespeak.net
Mon Sep 13 23:11:02 CEST 2010


Author: afa
Date: Mon Sep 13 23:10:59 2010
New Revision: 77049

Added:
   pypy/branch/fast-forward/lib-python/modified-2.7.0/opcode.py
      - copied, changed from r77048, pypy/branch/fast-forward/lib-python/2.7.0/opcode.py
   pypy/branch/fast-forward/lib-python/modified-2.7.0/sysconfig.py
      - copied, changed from r77048, pypy/branch/fast-forward/lib-python/2.7.0/sysconfig.py
   pypy/branch/fast-forward/lib-python/modified-2.7.0/test/regrtest.py
      - copied, changed from r77048, pypy/branch/fast-forward/lib-python/2.7.0/test/regrtest.py
   pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_support.py
      - copied unchanged from r77048, pypy/branch/fast-forward/lib-python/2.7.0/test/test_support.py
   pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_sys.py
      - copied, changed from r77048, pypy/branch/fast-forward/lib-python/2.7.0/test/test_sys.py
Modified:
   pypy/branch/fast-forward/lib-python/   (props changed)
Log:
Import the CPython 2.7.0 library.
a "svn:externals" is not practical here, since there is no way to
track and merge the eventual changes into modified-2.7.0


Copied: pypy/branch/fast-forward/lib-python/modified-2.7.0/opcode.py (from r77048, pypy/branch/fast-forward/lib-python/2.7.0/opcode.py)
==============================================================================
--- pypy/branch/fast-forward/lib-python/2.7.0/opcode.py	(original)
+++ pypy/branch/fast-forward/lib-python/modified-2.7.0/opcode.py	Mon Sep 13 23:10:59 2010
@@ -189,4 +189,9 @@
 def_op('SET_ADD', 146)
 def_op('MAP_ADD', 147)
 
+# pypy modification, experimental bytecode
+def_op('CALL_LIKELY_BUILTIN', 200)    # #args + (#kwargs << 8)
+def_op('LOOKUP_METHOD', 201)          # Index in name list
+def_op('CALL_METHOD', 202)            # #args not including 'self'
+
 del def_op, name_op, jrel_op, jabs_op

Copied: pypy/branch/fast-forward/lib-python/modified-2.7.0/sysconfig.py (from r77048, pypy/branch/fast-forward/lib-python/2.7.0/sysconfig.py)
==============================================================================
--- pypy/branch/fast-forward/lib-python/2.7.0/sysconfig.py	(original)
+++ pypy/branch/fast-forward/lib-python/modified-2.7.0/sysconfig.py	Mon Sep 13 23:10:59 2010
@@ -175,135 +175,9 @@
     return env_base if env_base else joinuser("~", ".local")
 
 
-def _parse_makefile(filename, vars=None):
-    """Parse a Makefile-style file.
-
-    A dictionary containing name/value pairs is returned.  If an
-    optional dictionary is passed in as the second argument, it is
-    used instead of a new dictionary.
-    """
-    import re
-    # Regexes needed for parsing Makefile (and similar syntaxes,
-    # like old-style Setup files).
-    _variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)")
-    _findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)")
-    _findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}")
-
-    if vars is None:
-        vars = {}
-    done = {}
-    notdone = {}
-
-    with open(filename) as f:
-        lines = f.readlines()
-
-    for line in lines:
-        if line.startswith('#') or line.strip() == '':
-            continue
-        m = _variable_rx.match(line)
-        if m:
-            n, v = m.group(1, 2)
-            v = v.strip()
-            # `$$' is a literal `$' in make
-            tmpv = v.replace('$$', '')
-
-            if "$" in tmpv:
-                notdone[n] = v
-            else:
-                try:
-                    v = int(v)
-                except ValueError:
-                    # insert literal `$'
-                    done[n] = v.replace('$$', '$')
-                else:
-                    done[n] = v
-
-    # do variable interpolation here
-    while notdone:
-        for name in notdone.keys():
-            value = notdone[name]
-            m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
-            if m:
-                n = m.group(1)
-                found = True
-                if n in done:
-                    item = str(done[n])
-                elif n in notdone:
-                    # get it on a subsequent round
-                    found = False
-                elif n in os.environ:
-                    # do it like make: fall back to environment
-                    item = os.environ[n]
-                else:
-                    done[n] = item = ""
-                if found:
-                    after = value[m.end():]
-                    value = value[:m.start()] + item + after
-                    if "$" in after:
-                        notdone[name] = value
-                    else:
-                        try: value = int(value)
-                        except ValueError:
-                            done[name] = value.strip()
-                        else:
-                            done[name] = value
-                        del notdone[name]
-            else:
-                # bogus variable reference; just drop it since we can't deal
-                del notdone[name]
-    # save the results in the global dictionary
-    vars.update(done)
-    return vars
-
-
-def _get_makefile_filename():
-    if _PYTHON_BUILD:
-        return os.path.join(_PROJECT_BASE, "Makefile")
-    return os.path.join(get_path('stdlib'), "config", "Makefile")
-
-
 def _init_posix(vars):
     """Initialize the module as appropriate for POSIX systems."""
-    # load the installed Makefile:
-    makefile = _get_makefile_filename()
-    try:
-        _parse_makefile(makefile, vars)
-    except IOError, e:
-        msg = "invalid Python installation: unable to open %s" % makefile
-        if hasattr(e, "strerror"):
-            msg = msg + " (%s)" % e.strerror
-        raise IOError(msg)
-
-    # load the installed pyconfig.h:
-    config_h = get_config_h_filename()
-    try:
-        parse_config_h(open(config_h), vars)
-    except IOError, e:
-        msg = "invalid Python installation: unable to open %s" % config_h
-        if hasattr(e, "strerror"):
-            msg = msg + " (%s)" % e.strerror
-        raise IOError(msg)
-
-    # On MacOSX we need to check the setting of the environment variable
-    # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
-    # it needs to be compatible.
-    # If it isn't set we set it to the configure-time value
-    if sys.platform == 'darwin' and 'MACOSX_DEPLOYMENT_TARGET' in vars:
-        cfg_target = vars['MACOSX_DEPLOYMENT_TARGET']
-        cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
-        if cur_target == '':
-            cur_target = cfg_target
-            os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target)
-        elif map(int, cfg_target.split('.')) > map(int, cur_target.split('.')):
-            msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" '
-                   'during configure' % (cur_target, cfg_target))
-            raise IOError(msg)
-
-    # On AIX, there are wrong paths to the linker scripts in the Makefile
-    # -- these paths are relative to the Python source, but when installed
-    # the scripts are in another directory.
-    if _PYTHON_BUILD:
-        vars['LDSHARED'] = vars['BLDSHARED']
+    return
 
 def _init_non_posix(vars):
     """Initialize the module as appropriate for NT"""

Copied: pypy/branch/fast-forward/lib-python/modified-2.7.0/test/regrtest.py (from r77048, pypy/branch/fast-forward/lib-python/2.7.0/test/regrtest.py)
==============================================================================
--- pypy/branch/fast-forward/lib-python/2.7.0/test/regrtest.py	(original)
+++ pypy/branch/fast-forward/lib-python/modified-2.7.0/test/regrtest.py	Mon Sep 13 23:10:59 2010
@@ -682,8 +682,13 @@
 
 def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
     """Return a list of all applicable test modules."""
-    testdir = findtestdir(testdir)
-    names = os.listdir(testdir)
+    if testdir:
+        testdirs = [testdir]
+    else:
+        testdirs = findtestdirs()
+    names = {}
+    for testdir in testdirs:
+        names.update(dict.fromkeys(os.listdir(testdir)))
     tests = []
     others = set(stdtests) | nottests
     for name in names:
@@ -850,7 +855,6 @@
 def runtest_inner(test, verbose, quiet,
                   testdir=None, huntrleaks=False):
     test_support.unload(test)
-    testdir = findtestdir(testdir)
     if verbose:
         capture_stdout = None
     else:
@@ -1079,8 +1083,19 @@
     # Collect cyclic trash.
     gc.collect()
 
-def findtestdir(path=None):
-    return path or os.path.dirname(__file__) or os.curdir
+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 removepy(names):
     if not names:
@@ -1501,13 +1516,7 @@
         return self.expected
 
 if __name__ == '__main__':
-    # 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
+    # Simplification for findtestdir().
     assert __file__ == os.path.abspath(sys.argv[0])
 
     # When tests are run from the Python build directory, it is best practice

Copied: pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_sys.py (from r77048, pypy/branch/fast-forward/lib-python/2.7.0/test/test_sys.py)
==============================================================================
--- pypy/branch/fast-forward/lib-python/2.7.0/test/test_sys.py	(original)
+++ pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_sys.py	Mon Sep 13 23:10:59 2010
@@ -264,6 +264,7 @@
             self.assertEqual(sys.getdlopenflags(), oldflags+1)
             sys.setdlopenflags(oldflags)
 
+    @test.test_support.impl_detail("reference counting")
     def test_refcount(self):
         # n here must be a global in order for this test to pass while
         # tracing with a python function.  Tracing calls PyFrame_FastToLocals
@@ -287,7 +288,7 @@
             is sys._getframe().f_code
         )
 
-    # sys._current_frames() is a CPython-only gimmick.
+    @test.test_support.impl_detail("current_frames")
     def test_current_frames(self):
         have_threads = True
         try:



More information about the Pypy-commit mailing list