Skip to content

Commit

Permalink
pythongh-102038: Skip a sometimes unnecessary stat in site.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Feb 19, 2023
1 parent 244d4cd commit b120191
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Lib/site.py
Expand Up @@ -492,20 +492,23 @@ def venv(known_paths):
executable = sys._base_executable = os.environ['__PYVENV_LAUNCHER__']
else:
executable = sys.executable
exe_dir, _ = os.path.split(os.path.abspath(executable))
exe_dir = os.path.dirname(os.path.abspath(executable))
site_prefix = os.path.dirname(exe_dir)
sys._home = None
conf_basename = 'pyvenv.cfg'
candidate_confs = [
conffile for conffile in (
os.path.join(exe_dir, conf_basename),
os.path.join(site_prefix, conf_basename)
candidate_conf = next(
(
conffile for conffile in (
os.path.join(exe_dir, conf_basename),
os.path.join(site_prefix, conf_basename)
)
if os.path.isfile(conffile)
]
if os.path.isfile(conffile)
),
None
)

if candidate_confs:
virtual_conf = candidate_confs[0]
if candidate_conf:
virtual_conf = candidate_conf
system_site = "true"
# Issue 25185: Use UTF-8, as that's what the venv module uses when
# writing the file.
Expand Down

0 comments on commit b120191

Please sign in to comment.