Skip to content

Commit

Permalink
fix infinite recursion when PEX_PYTHON points at a symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Landis committed Nov 19, 2015
1 parent 000a8e5 commit 0549e4b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pex/pex_bootstrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def maybe_reexec_pex():
from .tracer import TRACER

target_python = ENV.PEX_PYTHON
target = find_in_path(target_python)
target = os.path.realpath(find_in_path(target_python))
if not target:
die('Failed to find interpreter specified by PEX_PYTHON: %s' % target)
current = os.path.realpath(sys.executable)
Expand Down
20 changes: 19 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

import os
import sys

from twitter.common.contextutil import temporary_file
from twitter.common.contextutil import environment_as, temporary_dir, temporary_file

from pex.testing import run_simple_pex_test

Expand All @@ -30,3 +31,20 @@ def test_pex_interpreter():
so, rc = run_simple_pex_test("", args=(fp.name,), coverage=True, env=env)
assert so == b'Hello world\n'
assert rc == 0


def test_pex_python_symlink():
with temporary_dir() as td:
with environment_as(HOME=td):
symlink_path = os.path.join(td, 'python-symlink')
os.symlink(sys.executable, symlink_path)
pexrc_path = os.path.join(td, '.pexrc')
try:
with open(pexrc_path, 'w') as pexrc:
pexrc.write("PEX_PYTHON=%s" % symlink_path)

body = "print('Hello')"
_, rc = run_simple_pex_test(body, coverage=True)
assert rc == 0
finally:
os.unlink(pexrc_path)

0 comments on commit 0549e4b

Please sign in to comment.