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: "debug print(" crashes with SyntaxError #80112

Closed
blueyed mannequin opened this issue Feb 7, 2019 · 12 comments
Closed

pdb: "debug print(" crashes with SyntaxError #80112

blueyed mannequin opened this issue Feb 7, 2019 · 12 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@blueyed
Copy link
Mannequin

blueyed mannequin commented Feb 7, 2019

BPO 35931
Nosy @blueyed, @ned-deily, @ambv, @zware, @eamanu, @miss-islington, @remilapeyre
PRs
  • bpo-35931: Gracefully handle SyntaxError in pdb debug command #11782
  • bpo-35931: Gracefully handle SyntaxError in pdb debug command #11782
  • [3.7] bpo-35931: Gracefully handle SyntaxError in pdb debug command (GH-11782) #11886
  • bpo-35931: Gracefully handle any exception in pdb debug command #12103
  • [3.7] bpo-35931: Gracefully handle any exception in pdb debug command (GH-12103) #12285
  • 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 2019-03-12.04:02:55.136>
    created_at = <Date 2019-02-07.16:02:51.406>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'pdb: "debug print(" crashes with SyntaxError'
    updated_at = <Date 2019-03-12.04:02:55.131>
    user = 'https://github.com/blueyed'

    bugs.python.org fields:

    activity = <Date 2019-03-12.04:02:55.131>
    actor = 'zach.ware'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-03-12.04:02:55.136>
    closer = 'zach.ware'
    components = ['Library (Lib)']
    creation = <Date 2019-02-07.16:02:51.406>
    creator = 'blueyed'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35931
    keywords = ['patch', 'patch']
    message_count = 12.0
    messages = ['335025', '335643', '335645', '335646', '335647', '335649', '336862', '337575', '337576', '337714', '337716', '337717']
    nosy_count = 7.0
    nosy_names = ['blueyed', 'ned.deily', 'lukasz.langa', 'zach.ware', 'eamanu', 'miss-islington', 'remi.lapeyre']
    pr_nums = ['11782', '11782', '11886', '12103', '12285']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35931'
    versions = ['Python 3.7', 'Python 3.8']

    @blueyed
    Copy link
    Mannequin Author

    blueyed mannequin commented Feb 7, 2019

    debug print( will make pdb crash with a SyntaxError:

        % python -c '__import__("pdb").set_trace()'          
        --Return--
        > <string>(1)<module>()->None
        (Pdb) print(
        *** SyntaxError: unexpected EOF while parsing
        (Pdb) debug print(
        ENTERING RECURSIVE DEBUGGER
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/usr/lib64/python3.7/bdb.py", line 92, in trace_dispatch
            return self.dispatch_return(frame, arg)
          File "/usr/lib64/python3.7/bdb.py", line 151, in dispatch_return
            self.user_return(frame, arg)
          File "/usr/lib64/python3.7/pdb.py", line 293, in user_return
            self.interaction(frame, None)
          File "/usr/lib64/python3.7/pdb.py", line 352, in interaction
            self._cmdloop()
          File "/usr/lib64/python3.7/pdb.py", line 321, in _cmdloop
            self.cmdloop()
          File "/usr/lib64/python3.7/cmd.py", line 138, in cmdloop
            stop = self.onecmd(line)
          File "/usr/lib64/python3.7/pdb.py", line 418, in onecmd
            return cmd.Cmd.onecmd(self, line)
          File "/usr/lib64/python3.7/cmd.py", line 217, in onecmd
            return func(arg)
          File "/usr/lib64/python3.7/pdb.py", line 1099, in do_debug
            sys.call_tracing(p.run, (arg, globals, locals))
          File "/usr/lib64/python3.7/bdb.py", line 582, in run
            cmd = compile(cmd, "<string>", "exec")
          File "<string>", line 1
            print(
                 ^
        SyntaxError: unexpected EOF while parsing

    @blueyed blueyed mannequin added 3.8 only security fixes stdlib Python modules in the Lib dir labels Feb 7, 2019
    @eamanu
    Copy link
    Mannequin

    eamanu mannequin commented Feb 15, 2019

    ping reviewer :-)

    I test this PR and work fine on Ubuntu 18.04

    @miss-islington
    Copy link
    Contributor

    New changeset 4327705 by Miss Islington (bot) (Daniel Hahler) in branch 'master':
    bpo-35931: Gracefully handle SyntaxError in pdb debug command (GH-11782)
    4327705

    @miss-islington
    Copy link
    Contributor

    New changeset 6f35219 by Miss Islington (bot) in branch '3.7':
    bpo-35931: Gracefully handle SyntaxError in pdb debug command (GH-11782)
    6f35219

    @zware
    Copy link
    Member

    zware commented Feb 15, 2019

    Thanks for the patch!

    @zware zware added the 3.7 (EOL) end of life label Feb 15, 2019
    @zware zware closed this as completed Feb 15, 2019
    @blueyed
    Copy link
    Mannequin Author

    blueyed mannequin commented Feb 15, 2019

    Thanks for the review and backport!

    @blueyed
    Copy link
    Mannequin Author

    blueyed mannequin commented Feb 28, 2019

    Re-opening: it currently still crashes with a NameError when using "debug doesnotexist", or "debug doesnotexist()".

    Will create a new PR for this.

    @blueyed blueyed mannequin reopened this Feb 28, 2019
    @blueyed
    Copy link
    Mannequin Author

    blueyed mannequin commented Mar 9, 2019

    Bumping.

    The first (merged) patch is not sufficient, and causes even an API breakage, because it disallows passing in a code object (via compile()) anymore.

    A better fix is waiting at #12103, and should also get backported to for 3.7.3 then (or the first backport being reverted).

    @blueyed
    Copy link
    Mannequin Author

    blueyed mannequin commented Mar 9, 2019

    Example of the API breakage:

    /opt/python/3.8-dev/lib/python3.8/pdb.py:321: in _cmdloop
        self.cmdloop()
    /opt/python/3.8-dev/lib/python3.8/cmd.py:138: in cmdloop
        stop = self.onecmd(line)
    /opt/python/3.8-dev/lib/python3.8/pdb.py:418: in onecmd
        return cmd.Cmd.onecmd(self, line)
    /opt/python/3.8-dev/lib/python3.8/cmd.py:217: in onecmd
        return func(arg)
    pdb.py:699: in do_debug
        return orig_do_debug(self, cmd)
    /opt/python/3.8-dev/lib/python3.8/pdb.py:1097: in do_debug
        code = compile(arg, "<string>", "exec")
    E   TypeError: compile() arg 1 must be a string, bytes or AST object
    

    (via https://travis-ci.org/antocuni/pdb/jobs/504061679#L367)

    @miss-islington
    Copy link
    Contributor

    New changeset 3e93643 by Miss Islington (bot) (Daniel Hahler) in branch 'master':
    bpo-35931: Gracefully handle any exception in pdb debug command (GH-12103)
    3e93643

    @miss-islington
    Copy link
    Contributor

    New changeset 1c4580d by Miss Islington (bot) in branch '3.7':
    [3.7] bpo-35931: Gracefully handle any exception in pdb debug command (GH-12103) (GH-12285)
    1c4580d

    @zware
    Copy link
    Member

    zware commented Mar 12, 2019

    Thanks for catching that and fixing it before 3.7.3!

    @zware zware closed this as completed Mar 12, 2019
    @zware zware added type-bug An unexpected behavior, bug, or error and removed release-blocker labels Mar 12, 2019
    @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.7 (EOL) end of life 3.8 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

    3 participants