Commit 840a5eae authored by Kirill Smelkov's avatar Kirill Smelkov

gpython: '-' means gpython should read program file from stdin

Reported by @jerome here:
nexedi/slapos!862 (comment 121738)
parent 8564dfdd
......@@ -157,7 +157,7 @@ def pymain(argv, init=None):
reexec_argv += argv
if run is None:
# file
if len(argv) > 0:
if len(argv) > 0 and argv[0] != '-':
sys.argv = argv
filepath = argv[0]
......@@ -173,7 +173,7 @@ def pymain(argv, init=None):
# interactive console
else:
sys.argv = ['']
sys.argv = [''] if len(argv) == 0 else argv # e.g. ['-']
sys.path.insert(0, '') # cwd
def run():
......
......@@ -163,6 +163,10 @@ def test_pymain():
# interactive
_ = pyout([], stdin=b'import hello\n', cwd=testdata)
assert _ == b"hello\nworld\n['']\n"
_ = pyout(['-'], stdin=b'import hello\n', cwd=testdata)
assert _ == b"hello\nworld\n['-']\n"
_ = pyout(['-', 'zzz'], stdin=b'import hello\n', cwd=testdata)
assert _ == b"hello\nworld\n['-', 'zzz']\n"
# -c <command>
_ = pyout(['-c', 'import hello', 'abc', 'def'], cwd=testdata)
......
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