File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import sys
6
6
7
- # The Python interpreter unconditionally prepends the directory containing this
7
+ # By default the Python interpreter prepends the directory containing this
8
8
# script (following symlinks) to the import path. This is the cause of #9239,
9
- # and is a special case of #7091. We therefore explicitly delete that entry.
10
- # TODO(#7091): Remove this hack when no longer necessary.
11
- # TODO: Use sys.flags.safe_path to determine whether this removal should be
12
- # performed
13
- del sys .path [0 ]
9
+ # and is a special case of #7091.
10
+ #
11
+ # Python 3.11 introduced an PYTHONSAFEPATH (-P) option that disables this
12
+ # behaviour, which we set in the stage 1 bootstrap.
13
+ # So the prepended entry needs to be removed only if the above option is either
14
+ # unset or not supported by the interpreter.
15
+ # TODO(#7091): Remove this hack when we drop support for Python 3.10 and below
16
+ if not getattr (sys .flags , "safe_path" , False ):
17
+ del sys .path [0 ]
14
18
15
19
import contextlib
16
20
import os
You can’t perform that action at this time.
0 commit comments