[New-bugs-announce] [issue42384] Inconsistent sys.path between python and pdb

Andrey Bienkowski report at bugs.python.org
Tue Nov 17 02:46:41 EST 2020


New submission from Andrey Bienkowski <hexagonrecursion at gmail.com>:

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

pprint(sys.path)
$ python3 print-path.py 
['/home/user',
 '/usr/lib64/python38.zip',
 '/usr/lib64/python3.8',
 '/usr/lib64/python3.8/lib-dynload',
 '/usr/lib64/python3.8/site-packages',
 '/usr/lib/python3.8/site-packages']
$ python3 -m pdb print-path.py                                  
> /home/user/print-path.py(1)<module>()
-> import sys
(Pdb) c
['',
 '/usr/lib64/python38.zip',
 '/usr/lib64/python3.8',
 '/usr/lib64/python3.8/lib-dynload',
 '/usr/lib64/python3.8/site-packages',
 '/usr/lib/python3.8/site-packages']

----------
messages: 381215
nosy: hexagonrecursion
priority: normal
severity: normal
status: open
title: Inconsistent sys.path between python and pdb

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42384>
_______________________________________


More information about the New-bugs-announce mailing list