You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent sys.path between python and pdb #86550
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2021-01-26.15:59:07.336>created_at=<Date2020-11-17.07:46:41.774>labels= []
title='Inconsistent sys.path between python and pdb'updated_at=<Date2021-01-26.15:59:07.335>user='https://github.com/hexagonrecursion'
The first entry in sys.path is different between python foo.py and python -m pdb foo.py. In the former it is the absolute path to the parent directory of foo.py while in the later it is a relative path (unless the debug target was specified using an absolute path). The meaning of the absolute path does not change when the current directory changes (e.g. via os.chdir()) while the meaning of the relative path does. Like any environment inconsistency between regular program execution and the debugger this may lead to bugs that mysteriously vanish when you try to debug them.
$ cat > print-path.py
import sys
from pprint import pprint
Hey Andrey, this has been merged into 3.10, but the backports didn't work because the structure of the tests has changed (os_helper doesn't exist). Do you want to fix these?
Activity
hexagonrecursion commentedon Nov 17, 2020
The first entry in sys.path is different between
python foo.pyandpython -m pdb foo.py. In the former it is the absolute path to the parent directory of foo.py while in the later it is a relative path (unless the debug target was specified using an absolute path). The meaning of the absolute path does not change when the current directory changes (e.g. via os.chdir()) while the meaning of the relative path does. Like any environment inconsistency between regular program execution and the debugger this may lead to bugs that mysteriously vanish when you try to debug them.$ cat > print-path.py import sys from pprint import pprinthexagonrecursion commentedon Nov 17, 2020
I'll look into fixing this after I fix bpo-42383
hexagonrecursion commentedon Nov 17, 2020
After reading Lib/pdb.py:main I believe I can fix both by changing a single line.
miss-islington commentedon Jan 22, 2021
New changeset 8603dfb by Andrey Bienkowski in branch 'master':
bpo-42384: pdb: correctly populate sys.path[0] (GH-23338)
8603dfb
gvanrossum commentedon Jan 22, 2021
Hey Andrey, this has been merged into 3.10, but the backports didn't work because the structure of the tests has changed (os_helper doesn't exist). Do you want to fix these?
hexagonrecursion commentedon Jan 22, 2021
I'll give it a try
gvanrossum commentedon Jan 25, 2021
New changeset f2df795 by Andrey Bienkowski in branch '3.9':
[3.9] bpo-42384: pdb: correctly populate sys.path[0] (GH-23338) (bpo-24321)
f2df795
gvanrossum commentedon Jan 25, 2021
New changeset c10180e by Andrey Bienkowski in branch '3.8':
[3.8] bpo-42384: pdb: correctly populate sys.path[0] (GH-23338) (bpo-24320)
c10180e