Make sure we don't end up with an empty PYTHONPATH (#16240)
When the PYTHONPATH is an empty string python will treat it as though the cwd is in the PYTHONPATH. This can be undesirable. So make sure we delete PYTHONPATH from the environment altgether in this case. Fixes #16195
This commit is contained in:
parent
73a3a5839b
commit
7248314233
1 changed files with 2 additions and 0 deletions
|
@ -2022,6 +2022,8 @@ class AnsibleModule(object):
|
|||
if not x.endswith('/ansible_modlib.zip') \
|
||||
and not x.endswith('/debug_dir')]
|
||||
os.environ['PYTHONPATH'] = ':'.join(pypaths)
|
||||
if not os.environ['PYTHONPATH']:
|
||||
del os.environ['PYTHONPATH']
|
||||
|
||||
# create a printable version of the command for use
|
||||
# in reporting later, which strips out things like
|
||||
|
|
Loading…
Reference in a new issue