New submission from Andrey Bienkowski <hexagonrecurs...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue42384>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to