Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdb does not correclty restart the target if it changes the current directory #86549

Closed
hexagonrecursion mannequin opened this issue Nov 17, 2020 · 5 comments
Closed
Labels
3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@hexagonrecursion
Copy link
Mannequin

hexagonrecursion mannequin commented Nov 17, 2020

BPO 42383
Nosy @gvanrossum, @hexagonrecursion
PRs
  • bpo-42384: pdb: correctly populate sys.path[0] #23338
  • bpo-42383: pdb: do not fail to restart the target if the current directory changed #23412
  • [3.9] bpo-42383: pdb: do not fail to restart the target if the current directory changed (GH-23412) #24322
  • [3.8] bpo-42383: pdb: do not fail to restart the target if the current directory changed (GH-23412) #24323
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-01-26.15:58:50.341>
    created_at = <Date 2020-11-17.07:26:31.650>
    labels = ['3.8', 'type-bug', 'library', '3.9', '3.10']
    title = 'Pdb does not correclty restart the target if it changes the current directory'
    updated_at = <Date 2021-01-26.15:58:50.341>
    user = 'https://github.com/hexagonrecursion'

    bugs.python.org fields:

    activity = <Date 2021-01-26.15:58:50.341>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-01-26.15:58:50.341>
    closer = 'gvanrossum'
    components = ['Library (Lib)']
    creation = <Date 2020-11-17.07:26:31.650>
    creator = 'hexagonrecursion'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42383
    keywords = ['patch']
    message_count = 5.0
    messages = ['381213', '381216', '385665', '385722', '385723']
    nosy_count = 2.0
    nosy_names = ['gvanrossum', 'hexagonrecursion']
    pr_nums = ['23338', '23412', '24322', '24323']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue42383'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @hexagonrecursion
    Copy link
    Mannequin Author

    hexagonrecursion mannequin commented Nov 17, 2020

    This was mentioned in bpo-31121, but I believe this deserves its own separate issue. If the debug target is specified using a relative path and later the current directory is changed, pdb tries to search for the target in the new current directory. This currently causes pdb to be unable to exit, which is what bpo-31121 and bpo-14743 are about, but even if they are fixed we would still be left with pdb exiting instead of restarting the target. This issues is about the latter.

    To reproduce (same as bpo-31121):

    $ mkdir foo
    $ cat > foo/script.py
    import os
    os.chdir('foo')
    $ python3 -m pdb foo/script.py 
    > /home/user/foo/script.py(1)<module>()
    -> import os
    (Pdb) c
    The program finished and will be restarted
    Traceback (most recent call last):
      File "/usr/lib64/python3.8/pdb.py", line 1704, in main
        pdb._runscript(mainpyfile)
      File "/usr/lib64/python3.8/pdb.py", line 1570, in _runscript
        with io.open_code(filename) as fp:
    FileNotFoundError: [Errno 2] No such file or directory: 'foo/script.py'
    Uncaught exception. Entering post mortem debugging
    Running 'cont' or 'step' will restart the program
    > /usr/lib64/python3.8/pdb.py(1570)_runscript()
    -> with io.open_code(filename) as fp:

    @hexagonrecursion
    Copy link
    Mannequin Author

    hexagonrecursion mannequin commented Nov 17, 2020

    I'm working on fixing this

    @E-Paine E-Paine mannequin added stdlib Python modules in the Lib dir 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes type-bug An unexpected behavior, bug, or error labels Nov 28, 2020
    @gvanrossum
    Copy link
    Member

    New changeset 501d4a5 by Andrey Bienkowski in branch 'master':
    bpo-42383: pdb: do not fail to restart the target if the current directory changed (bpo-23412)
    501d4a5

    @gvanrossum
    Copy link
    Member

    New changeset f8cfe54 by Andrey Bienkowski in branch '3.9':
    [3.9] bpo-42383: pdb: do not fail to restart the target if the current directory changed (GH-23412) (bpo-24322)
    f8cfe54

    @gvanrossum
    Copy link
    Member

    New changeset d863dee by Andrey Bienkowski in branch '3.8':
    [3.8] bpo-42383: pdb: do not fail to restart the target if the current directory changed (GH-23412) (bpo-24323)
    d863dee

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant