bpo-42384: pdb: correctly populate sys.path[0] (GH-23338)

Automerge-Triggered-By: GH:gvanrossum
This commit is contained in:
Andrey Bienkowski 2021-01-22 01:19:51 +00:00 committed by GitHub
parent 5e45f1c8e7
commit 8603dfb421
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View file

@ -1686,8 +1686,9 @@ def main():
sys.argv[:] = args # Hide "pdb.py" and pdb options from argument list
# Replace pdb's dir with script's dir in front of module search path.
if not run_as_module:
mainpyfile = os.path.realpath(mainpyfile)
# Replace pdb's dir with script's dir in front of module search path.
sys.path[0] = os.path.dirname(mainpyfile)
# Note on saving/restoring sys.argv: it's a good idea when sys.argv was