[pypy-svn] pypy commit 9a60739ea753: Merge from default

Bitbucket commits-noreply at bitbucket.org
Wed Dec 15 00:56:29 CET 2010


# HG changeset patch -- Bitbucket.org
# Project pypy
# URL http://bitbucket.org/pypy/pypy/overview
# User Amaury Forgeot d'Arc <amauryfa at gmail.com>
# Date 1292371014 -3600
# Node ID 9a60739ea7531597d69b1cfba6ff6e62a1e28301
# Parent  655ca5f1175cb92ed5fe95bc21ea0c87b691a693
# Parent  e7bff972e4ad3dcb64457adc95d28e7dab38d391
Merge from default

--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -207,7 +207,10 @@ def get_library_path(executable):
         break      # found!
     return newpath
 
-def setup_initial_paths(executable, ignore_environment=False, **extra):
+def setup_sys_executable(executable, nanos):
+    # a substituted os if we are translated
+    global os
+    os = nanos
     # find the full path to the executable, assuming that if there is no '/'
     # in the provided one then we must look along the $PATH
     if we_are_translated() and IS_WINDOWS and not executable.lower().endswith('.exe'):
@@ -224,7 +227,8 @@ def setup_initial_paths(executable, igno
                     break
     sys.executable = os.path.abspath(executable)
 
-    newpath = get_library_path(executable)
+def setup_initial_paths(ignore_environment=False, **extra):
+    newpath = get_library_path(sys.executable)
     readenv = not ignore_environment
     path = readenv and os.getenv('PYTHONPATH')
     if path:
@@ -575,15 +579,13 @@ def print_banner():
            '"license" for more information.')
 
 def entry_point(executable, argv, nanos):
-    # a substituted os if we are translated
-    global os
-    os = nanos
+    setup_sys_executable(executable, nanos)
     try:
         cmdline = parse_command_line(argv)
     except CommandLineError, e:
         print_error(str(e))
         return 2
-    setup_initial_paths(executable, **cmdline)
+    setup_initial_paths(**cmdline)
     return run_command_line(**cmdline)
 
 

--- a/pypy/translator/goal/test2/test_app_main.py
+++ b/pypy/translator/goal/test2/test_app_main.py
@@ -188,6 +188,12 @@ class TestInteraction:
         child.sendline("'' in sys.path")
         child.expect("True")
 
+    def test_help(self):
+        # test that -h prints the usage, including the name of the executable
+        # which should be /full/path/to/app_main.py in this case
+        child = self.spawn(['-h'])
+        child.expect(r'usage: .*app_main.py \[options\]')
+
     def test_run_script(self):
         child = self.spawn([demo_script])
         idx = child.expect(['hello', 'Python ', '>>> '])

--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -485,13 +485,14 @@ class AppTestSysModulePortedFromCPython:
         assert revision.isdigit()
 
     def test__mercurial(self):
-        info = sys._mercurial
-        print info
-        if info:
-            project, hgtag, hgid = info
-            assert project == 'PyPy'
-            assert hgtag  # no clue how to check something more :-/
-            assert hgid
+        import re
+        project, hgtag, hgid = sys._mercurial
+        assert project == 'PyPy'
+        # the tag or branch may be anything, including the empty string
+        assert isinstance(hgtag, str)
+        # the id is either nothing, or an id of 12 hash digits, with a possible
+        # suffix of '+' if there are local modifications
+        assert hgid == '' or re.match('[0-9a-f]{12}\+?', hgid)
 
     def test_trace_exec_execfile(self):
         found = []



More information about the Pypy-commit mailing list