mirror of
https://github.com/python/cpython.git
synced 2025-01-23 01:32:36 +08:00
Closes #16340: Handle exception while copying script to venv.
This commit is contained in:
parent
6d50a5447a
commit
bdd13fd098
@ -305,11 +305,17 @@ class EnvBuilder:
|
||||
mode = 'wb'
|
||||
else:
|
||||
mode = 'w'
|
||||
data = data.decode('utf-8')
|
||||
data = self.replace_variables(data, context)
|
||||
with open(dstfile, mode) as f:
|
||||
f.write(data)
|
||||
shutil.copymode(srcfile, dstfile)
|
||||
try:
|
||||
data = data.decode('utf-8')
|
||||
data = self.replace_variables(data, context)
|
||||
except UnicodeDecodeError as e:
|
||||
data = None
|
||||
logger.warning('unable to copy script %r, '
|
||||
'may be binary: %s', srcfile, e)
|
||||
if data is not None:
|
||||
with open(dstfile, mode) as f:
|
||||
f.write(data)
|
||||
shutil.copymode(srcfile, dstfile)
|
||||
|
||||
|
||||
def create(env_dir, system_site_packages=False, clear=False, symlinks=False):
|
||||
|
Loading…
Reference in New Issue
Block a user