Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge #29285
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jan 2, 2022
2 parents 6b41c4a + 376932f commit 5f0c36c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions build/bin/sage-bootstrap-python
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ fi
# is accessible by this python; this is to guard on Cygwin against Pythons
# installed somewhere else in Windows.

# Trac #29285: Do not accept pythons that manipulate PATH, such as
# the shims provided by pyenv.

# Trac #30008: Make it work even if the environment tries to sabotage UTF-8
# operation in Python 3.0.x-3.6.x by setting LC_ALL=C or similar.

Expand All @@ -47,7 +50,7 @@ PYTHONS="python python3 python3.10 python3.9 python3.8 python3.7 python2.7 pytho
for PY in $PYTHONS; do
PYTHON="$(PATH="$SAGE_ORIG_PATH" command -v $PY)"
if [ -n "$PYTHON" ]; then
if "$PYTHON" -c "import argparse; import urllib; from hashlib import sha1; from ssl import HAS_SNI; assert HAS_SNI; from os import listdir; listdir(\"$(pwd)\");" 2>/dev/null; then
if CHECK_PATH="$PATH" "$PYTHON" -c "import argparse; import urllib; from hashlib import sha1; from ssl import HAS_SNI; assert HAS_SNI; from os import listdir, environ; listdir(\"$(pwd)\"); assert environ[\"PATH\"] == environ[\"CHECK_PATH\"];" 2>/dev/null; then
exec "$PYTHON" "$@"
fi
fi
Expand All @@ -56,10 +59,10 @@ done
for PY in $PYTHONS; do
PYTHON="$(PATH="$SAGE_ORIG_PATH" command -v $PY)"
if [ -n "$PYTHON" ]; then
if "$PYTHON" -c "import argparse; import urllib; from hashlib import sha1; from os import listdir; listdir(\"$(pwd)\");" 2>/dev/null; then
if CHECK_PATH="$PATH" "$PYTHON" -c "import argparse; import urllib; from hashlib import sha1; from os import listdir, environ; listdir(\"$(pwd)\"); assert environ[\"PATH\"] == environ[\"CHECK_PATH\"];" 2>/dev/null; then
exec "$PYTHON" "$@"
fi
fi
done
echo >&2 "$0: error: none of $PYTHONS is a suitable Python with urllib"
echo >&2 "$0: error: none of $PYTHONS is a suitable Python"
exit 1

0 comments on commit 5f0c36c

Please sign in to comment.