Skip to content

Pdb incorrectly handles a method breakpoint when module not imported #59000

Closed

Description

@xdegaye
mannequin
BPO 14795
Nosy @birkenfeld, @xdegaye
Files
  • pdb_default.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 = None
    created_at = <Date 2012-05-13.15:25:56.212>
    labels = ['type-bug', 'library']
    title = 'Pdb incorrectly handles a method breakpoint when module not imported'
    updated_at = <Date 2012-05-25.11:55:57.295>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2012-05-25.11:55:57.295>
    actor = 'xdegaye'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2012-05-13.15:25:56.212>
    creator = 'xdegaye'
    dependencies = []
    files = ['25560']
    hgrepos = []
    issue_num = 14795
    keywords = ['patch']
    message_count = 2.0
    messages = ['160517', '161573']
    nosy_count = 2.0
    nosy_names = ['georg.brandl', 'xdegaye']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue14795'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

    Linked PRs

    Activity

    1. xdegaye commented on May 13, 2012

      xdegayemannequin
      MannequinAuthor

      In the following test, breakpoint 2 is set incorrectly at line 1 and
      pdb does not know how to set a breakpoint on method C.c_foo. However
      setting those two breakpoints on both methods is ok after the class
      definition has been executed.

      === main.py =================================

      def foo():
          pass
      
      class C:
          def c_foo(self):
              pass
          def foo(self):
              pass
      
      foo()

      =================================================

      $ python3.1 -m pdb main.py
      > /path_to/main.py(1)<module>()
      -> def foo():
      (Pdb) import sys; print(sys.version)
      3.1.2 (r312:79147, Apr  4 2010, 17:46:48) 
      [GCC 4.3.2]
      (Pdb) break foo
      Breakpoint 1 at /path_to/main.py:1
      (Pdb) break C.foo
      Breakpoint 2 at /path_to/main.py:1
      (Pdb) break C.c_foo
      *** The specified object 'C.c_foo' is not a function
      or was not found along sys.path.
      (Pdb) break 10
      Breakpoint 3 at /path_to/main.py:10
      (Pdb) continue
      > /path_to/main.py(10)<module>()
      -> foo()
      (Pdb) break C.foo
      Breakpoint 4 at /path_to/main.py:7
      (Pdb) break C.c_foo
      Breakpoint 5 at /path_to/main.py:5
      (Pdb) quit

      =================================================

      The attached patch fixes the problem. The patch includes a test case.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on May 13, 2012
    3. xdegaye commented on May 25, 2012

      xdegayemannequin
      MannequinAuthor

      Parsing the modules source seems a better way to fix this problem, see bpo-14913.

    4. transferred this issue fromon Apr 10, 2022
    5. added a commit that references this issue on Dec 2, 2025
    6. added a commit that references this issue on Dec 2, 2025
    7. added a commit that references this issue on Dec 2, 2025
    8. added 2 commits that reference this issue on Dec 2, 2025
    9. added a commit that references this issue on Dec 6, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions