[pypy-commit] pypy default: issue #1991: fixed by removing sys.executable from the list of
arigo
noreply at buildbot.pypy.org
Wed Feb 25 10:54:39 CET 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r76116:19e305e27e67
Date: 2015-02-25 10:54 +0100
http://bitbucket.org/pypy/pypy/changeset/19e305e27e67/
Log: issue #1991: fixed by removing sys.executable from the list of
prebuilt attributes. Related fixes of other places that would end
up with sys.executable == 'py.py'.
diff --git a/pypy/doc/embedding.rst b/pypy/doc/embedding.rst
--- a/pypy/doc/embedding.rst
+++ b/pypy/doc/embedding.rst
@@ -36,7 +36,8 @@
"PyPy home directory". The arguments are:
* ``home``: NULL terminated path to an executable inside the pypy directory
- (can be a .so name, can be made up)
+ (can be a .so name, can be made up). Used to look up the standard
+ library, and is also set as ``sys.executable``.
* ``verbose``: if non-zero, it will print error messages to stderr
diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -106,6 +106,9 @@
space.call_function(w_pathsetter, w_path)
# import site
try:
+ space.setattr(space.getbuiltinmodule('sys'),
+ space.wrap('executable'),
+ space.wrap(home))
import_ = space.getattr(space.getbuiltinmodule('__builtin__'),
space.wrap('__import__'))
space.call_function(import_, space.wrap('site'))
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -1,5 +1,5 @@
#! /usr/bin/env python
-# App-level version of py.py.
+# This is pure Python code that handles the main entry point into "pypy".
# See test/test_app_main.
# Missing vs CPython: -d, -t, -v, -x, -3
@@ -157,10 +157,13 @@
current = group
raise SystemExit
+def get_sys_executable():
+ return getattr(sys, 'executable', 'pypy')
+
def print_help(*args):
import os
print 'usage: %s [option] ... [-c cmd | -m mod | file | -] [arg] ...' % (
- sys.executable,)
+ get_sys_executable(),)
print USAGE1,
if 'pypyjit' in sys.builtin_module_names:
print "--jit options: advanced JIT options: try 'off' or 'help'"
@@ -171,7 +174,7 @@
try:
import pypyjit
except ImportError:
- print >> sys.stderr, "No jit support in %s" % (sys.executable,)
+ print >> sys.stderr, "No jit support in %s" % (get_sys_executable(),)
return
items = sorted(pypyjit.defaults.items())
print 'Advanced JIT options: a comma-separated list of OPTION=VALUE:'
@@ -209,7 +212,7 @@
raise SystemExit
if 'pypyjit' not in sys.builtin_module_names:
print >> sys.stderr, ("Warning: No jit support in %s" %
- (sys.executable,))
+ (get_sys_executable(),))
else:
import pypyjit
pypyjit.set_param(jitparam)
@@ -219,8 +222,8 @@
def print_error(msg):
print >> sys.stderr, msg
- print >> sys.stderr, 'usage: %s [options]' % (sys.executable,)
- print >> sys.stderr, 'Try `%s -h` for more information.' % (sys.executable,)
+ print >> sys.stderr, 'usage: %s [options]' % (get_sys_executable(),)
+ print >> sys.stderr, 'Try `%s -h` for more information.' % (get_sys_executable(),)
def fdopen(fd, mode, bufsize=-1):
try:
diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py
--- a/pypy/interpreter/test/test_objspace.py
+++ b/pypy/interpreter/test/test_objspace.py
@@ -373,7 +373,7 @@
config = make_config(None)
space = make_objspace(config)
w_executable = space.wrap('executable')
- assert space.str_w(space.getattr(space.sys, w_executable)) == 'py.py'
+ assert space.findattr(space.sys, w_executable) is None
space.setattr(space.sys, w_executable, space.wrap('foobar'))
assert space.str_w(space.getattr(space.sys, w_executable)) == 'foobar'
space.startup()
diff --git a/pypy/interpreter/test/test_targetpypy.py b/pypy/interpreter/test/test_targetpypy.py
--- a/pypy/interpreter/test/test_targetpypy.py
+++ b/pypy/interpreter/test/test_targetpypy.py
@@ -8,7 +8,7 @@
entry_point = get_entry_point(config)[0]
entry_point(['pypy-c' , '-S', '-c', 'print 3'])
-def test_exeucte_source(space):
+def test_execute_source(space):
_, d = create_entry_point(space, None)
execute_source = d['pypy_execute_source']
lls = rffi.str2charp("import sys; sys.modules['xyz'] = 3")
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -64,7 +64,6 @@
'call_tracing' : 'vm.call_tracing',
'getsizeof' : 'vm.getsizeof',
- 'executable' : 'space.wrap("py.py")',
'api_version' : 'version.get_api_version(space)',
'version_info' : 'version.get_version_info(space)',
'version' : 'version.get_version(space)',
diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -500,7 +500,7 @@
assert isinstance(sys.builtin_module_names, tuple)
assert isinstance(sys.copyright, basestring)
#assert isinstance(sys.exec_prefix, basestring) -- not present!
- assert isinstance(sys.executable, basestring)
+ #assert isinstance(sys.executable, basestring) -- not present!
assert isinstance(sys.hexversion, int)
assert isinstance(sys.maxint, int)
assert isinstance(sys.maxsize, int)
@@ -519,6 +519,12 @@
assert vi[3] in ("alpha", "beta", "candidate", "final")
assert isinstance(vi[4], int)
+ def test_reload_doesnt_override_sys_executable(self):
+ import sys
+ sys.executable = 'from_test_sysmodule'
+ reload(sys)
+ assert sys.executable == 'from_test_sysmodule'
+
def test_settrace(self):
import sys
counts = []
More information about the pypy-commit
mailing list