Issue 42384: Inconsistent sys.path between python and pdb
Created on 2020-11-17 07:46 by hexagonrecursion, last changed 2021-01-26 15:59 by gvanrossum. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 23338 | merged | hexagonrecursion, 2020-11-17 11:36 | |
| PR 24290 | closed | miss-islington, 2021-01-22 01:20 | |
| PR 24291 | closed | miss-islington, 2021-01-22 01:20 | |
| PR 24320 | merged | hexagonrecursion, 2021-01-25 07:43 | |
| PR 24321 | merged | hexagonrecursion, 2021-01-25 08:10 | |
| PR 23412 | hexagonrecursion, 2021-01-25 08:47 | ||
| Messages (8) | |||
|---|---|---|---|
| msg381215 - (view) | Author: Andrey Bienkowski (hexagonrecursion) * | Date: 2020-11-17 07:46 | |
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'] |
|||
| 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/pdb.py:main I believe I can fix both by changing a single line. |
|||
| msg385464 - (view) | Author: miss-islington (miss-islington) | Date: 2021-01-22 01:20 | |
New changeset 8603dfb4219989644601f6ede75b57e82648cd4e by Andrey Bienkowski in branch 'master': bpo-42384: pdb: correctly populate sys.path[0] (GH-23338) https://github.com/python/cpython/commit/8603dfb4219989644601f6ede75b57e82648cd4e |
|||
| msg385470 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2021-01-22 03:28 | |
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? |
|||
| msg385482 - (view) | Author: Andrey Bienkowski (hexagonrecursion) * | Date: 2021-01-22 07:38 | |
I'll give it a try |
|||
| msg385666 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2021-01-25 21:08 | |
New changeset f2df7958fb82cd927e17152b3a1bd2823a76dd3e by Andrey Bienkowski in branch '3.9': [3.9] bpo-42384: pdb: correctly populate sys.path[0] (GH-23338) (#24321) https://github.com/python/cpython/commit/f2df7958fb82cd927e17152b3a1bd2823a76dd3e |
|||
| msg385667 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2021-01-25 21:10 | |
New changeset c10180ea1458aa0ffd7793cb75629ebffe8a257e by Andrey Bienkowski in branch '3.8': [3.8] bpo-42384: pdb: correctly populate sys.path[0] (GH-23338) (#24320) https://github.com/python/cpython/commit/c10180ea1458aa0ffd7793cb75629ebffe8a257e |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2021-01-26 15:59:07 | gvanrossum | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2021-01-25 21:10:49 | gvanrossum | set | messages: + msg385667 |
| 2021-01-25 21:08:50 | gvanrossum | set | messages: + msg385666 |
| 2021-01-25 08:47:33 | hexagonrecursion | set | pull_requests: + pull_request23141 |
| 2021-01-25 08:10:32 | hexagonrecursion | set | pull_requests: + pull_request23140 |
| 2021-01-25 07:43:58 | hexagonrecursion | set | pull_requests: + pull_request23139 |
| 2021-01-22 07:38:42 | hexagonrecursion | set | messages: + msg385482 |
| 2021-01-22 03:28:01 | gvanrossum | set | nosy:
+ gvanrossum messages: + msg385470 |
| 2021-01-22 01:20:17 | miss-islington | set | messages: + msg385464 |
| 2021-01-22 01:20:14 | miss-islington | set | pull_requests: + pull_request23112 |
| 2021-01-22 01:20:07 | miss-islington | set | nosy:
+ miss-islington pull_requests: + pull_request23111 |
| 2020-11-17 11:36:57 | hexagonrecursion | set | keywords:
+ patch stage: patch review pull_requests: + pull_request22228 |
| 2020-11-17 08:38:57 | hexagonrecursion | set | messages: + msg381219 |
| 2020-11-17 07:51:14 | hexagonrecursion | set | messages: + msg381218 |
| 2020-11-17 07:46:41 | hexagonrecursion | create | |
