omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Breakpoints in multiple modules

    Pythonista
    debugging breakpoints
    3
    5
    3271
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • robnee
      robnee last edited by

      Is there a trick to setting breakpoints across modules? If I have a python file, a.py that imports b.py and I set a breakpoint in b.py when I run a.py the breakpoint does not fire for me. The code in b.py runs fine. Just the breakpoint isn't firing Is there a way to use the debugger here? What am I missing?

      Thanks if you can help.

      1 Reply Last reply Reply Quote 0
      • robnee
        robnee last edited by

        Can anyone confirm whether one can set breakpoints in a project with multiple modules?

        1 Reply Last reply Reply Quote 0
        • mithrendal
          mithrendal last edited by mithrendal

          Hi @robnee
          huh, nobody answers to you. Ok I will try. From what I have seen, only breakpoints of the script on which you started the debug-session will fire. That means if you debug a.py only those breakpoints will fire.

          But what seems to work is some sort of multi-module or multiple script debugging. That means if you have your break in a.py then the debugger will perfectly step into b.py when you single step forward and the code leads into a method located in b.py

          1 Reply Last reply Reply Quote 0
          • robnee
            robnee last edited by

            Thanks. At least I'm not crazy. This really limits the usefulness of the debugger. Sometimes the call chain can be complex and stepping to get to the code I need to look at isn't feasible. I might try a few more things and report back.

            1 Reply Last reply Reply Quote 0
            • JonB
              JonB last edited by

              while not ideal, you can set breakpoints this way as well at the start of your main script:

              import debugger
              debugger.debugger.set_break(filename, lineno)
              debugger.debugger.set_break(filename, lineno2)

              and so on.

              There is probably a way using objc to query all open editor files for breakpoints. An almost worked through way this would work: cycle through editor tabs

              editor._get_editor_tab().parentViewController().tabViewControllers()
              

              getting the filepath from .filePath()
              checking for .editorView(), then

              bps=tab.editorView().breakPoints()
              lines=[1+i for i,entry in enumerate(list(bps)) if entry['active'] ]
              

              then add breakpoints as described above. This must happen after script is run, so either we pack this code into a import filebreaks, or else we can hijack pythonista_preflight the way dgelessus does in his pythonista_startup to disable global clearing.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors