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

cannot quit pdb when there is a syntax error in the debuggee (must kill it) #60384

Closed
xdegaye mannequin opened this issue Oct 9, 2012 · 7 comments
Closed

cannot quit pdb when there is a syntax error in the debuggee (must kill it) #60384

xdegaye mannequin opened this issue Oct 9, 2012 · 7 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@xdegaye
Copy link
Mannequin

xdegaye mannequin commented Oct 9, 2012

BPO 16180
Nosy @birkenfeld, @terryjreedy, @asvetlov, @xdegaye
Files
  • pdbloopfix.diff
  • pdb_syntax_error.patch
  • 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 2015-09-05.23:20:31.307>
    created_at = <Date 2012-10-09.19:33:24.075>
    labels = ['type-bug', 'library']
    title = 'cannot quit pdb when there is a syntax error in the debuggee (must kill it)'
    updated_at = <Date 2015-09-05.23:20:31.306>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2015-09-05.23:20:31.306>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-09-05.23:20:31.307>
    closer = 'terry.reedy'
    components = ['Library (Lib)']
    creation = <Date 2012-10-09.19:33:24.075>
    creator = 'xdegaye'
    dependencies = []
    files = ['40358', '40372']
    hgrepos = []
    issue_num = 16180
    keywords = ['patch']
    message_count = 7.0
    messages = ['172508', '175970', '176274', '249797', '249802', '249900', '249949']
    nosy_count = 6.0
    nosy_names = ['georg.brandl', 'terry.reedy', 'asvetlov', 'xdegaye', 'rurpy2', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16180'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Oct 9, 2012

    $ tmp=`mktemp /tmp/foo.XXXXXXXXXX`; echo 'def foo: pass' > $tmp; python3 -m pdb $tmp; rm $tmp
    Traceback (most recent call last):
      File "/usr/local/lib/python3.2/pdb.py", line 1556, in main
        pdb._runscript(mainpyfile)
      File "/usr/local/lib/python3.2/pdb.py", line 1437, in _runscript
        self.run(statement)
      File "/usr/local/lib/python3.2/bdb.py", line 392, in run
        exec(cmd, globals, locals)
      File "<string>", line 1, in <module>
      File "/tmp/foo.iLhPYHBZrF", line 1
        def foo: pass
               ^
    SyntaxError: invalid syntax
    Uncaught exception. Entering post mortem debugging
    Running 'cont' or 'step' will restart the program
    > <string>(1)<module>()
    (Pdb) quit
    Post mortem debugger finished. The /tmp/foo.iLhPYHBZrF will be restarted
    Traceback (most recent call last):
      File "/usr/local/lib/python3.2/pdb.py", line 1556, in main
        pdb._runscript(mainpyfile)
      File "/usr/local/lib/python3.2/pdb.py", line 1437, in _runscript
        self.run(statement)
      File "/usr/local/lib/python3.2/bdb.py", line 392, in run
        exec(cmd, globals, locals)
      File "<string>", line 1, in <module>
      File "/tmp/foo.iLhPYHBZrF", line 1
        def foo: pass
               ^
    SyntaxError: invalid syntax
    Uncaught exception. Entering post mortem debugging
    Running 'cont' or 'step' will restart the program
    > <string>(1)<module>()
    (Pdb) --KeyboardInterrupt--
    (Pdb)

    @xdegaye xdegaye mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Oct 9, 2012
    @rurpy2
    Copy link
    Mannequin

    rurpy2 mannequin commented Nov 19, 2012

    This continues to be a problem on Python-3.3.0

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Nov 24, 2012

    @terryjreedy
    Copy link
    Member

    Reported again in bpo-24957

    Xavier, your link is out of date.

    @terryjreedy
    Copy link
    Member

    Simple fix attached. I copied the exit code from this part of the 'while True:' loop.

        try:
            pdb._runscript(mainpyfile)
            if pdb._user_requested_quit:
                break
            print("The program finished and will be restarted")
    

    I am not sure if the conditional is still needed there.

    Xavier, if you have a better patch, please upload it.

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Sep 5, 2015

    Slightly better in that pdb exits in case of a syntax error instead of proposing to restart the program which does not make sense.

    A test case is included.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 5, 2015

    New changeset 26c4db1a0aea by Terry Jan Reedy in branch '2.7':
    Issue bpo-16180: Exit pdb if file has syntax error, instead of trapping user
    https://hg.python.org/cpython/rev/26c4db1a0aea

    New changeset 2d4aac2ab253 by Terry Jan Reedy in branch '3.4':
    Issue bpo-16180: Exit pdb if file has syntax error, instead of trapping user
    https://hg.python.org/cpython/rev/2d4aac2ab253

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    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