Title: Inconsistent sys.path between python and pdb
Type: Stage: patch review
Components: Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: hexagonrecursion
Priority: normal Keywords: patch

Created on 2020-11-17 07:46 by hexagonrecursion, last changed 2020-11-17 11:36 by hexagonrecursion.

Pull Requests
URL Status Linked Edit
PR 23338 open hexagonrecursion, 2020-11-17 11:36
Messages (3)
msg381215 - (view) Author: Andrey Bienkowski (hexagonrecursion) * Date: 2020-11-17 07:46
The first entry in sys.path is different between `python` and `python -m pdb`. In the former it is the absolute path to the parent directory of 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 >
import sys
from pprint import pprint

$ python3 
$ python3 -m pdb                                  
> /home/user/<module>()
-> import sys
(Pdb) c
msg381218 - (view) Author: Andrey Bienkowski (hexagonrecursion) * Date: 2020-11-17 07:51
I'll look into fixing this after I fix #42383
msg381219 - (view) Author: Andrey Bienkowski (hexagonrecursion) * Date: 2020-11-17 08:38
After reading Lib/ I believe I can fix both by changing a single line.
Date User Action Args
2020-11-17 11:36:57hexagonrecursionsetkeywords: + patch
stage: patch review
pull_requests: + pull_request22228
2020-11-17 08:38:57hexagonrecursionsetmessages: + msg381219
2020-11-17 07:51:14hexagonrecursionsetmessages: + msg381218
2020-11-17 07:46:41hexagonrecursioncreate