Message381215
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'] |
|
Date |
User |
Action |
Args |
2020-11-17 07:46:41 | hexagonrecursion | set | recipients:
+ hexagonrecursion |
2020-11-17 07:46:41 | hexagonrecursion | set | messageid: <1605599201.78.0.619329509169.issue42384@roundup.psfhosted.org> |
2020-11-17 07:46:41 | hexagonrecursion | link | issue42384 messages |
2020-11-17 07:46:41 | hexagonrecursion | create | |
|