[New-bugs-announce] [issue23331] Add non-interactive version of Bdb.runcall

Isaac Jurado report at bugs.python.org
Tue Jan 27 14:09:19 CET 2015

New submission from Isaac Jurado:

The Bdb.runcall method shows a prompt right at the beginning of the function.  If breakpoints are defined, it is sometimes handy to skip the prompt until the next breakpoint, if any.

This use case came up in our development environment for a Django application, from where we needed to set breakpoints only for certain request, allowing other request to run without interruption.  Our solution was to wrap with a WSGI middleware, something like this:

    import sys
    from bdb import BdbQuit
    from pdb import Pdb

    class DebuggingMiddleware(object):

        def __init__(self, app):
            self.aplicacion = app
            self.debugger = Pdb()

        def __call__(self, environ, start_response):
            environ['DEBUGGER'] = self.debugger
            frame = sys._getframe()
            frame.f_trace = self.debugger.trace_dispatch
            self.debugger.botframe = frame
            self.debugger._set_stopinfo(frame, None, -1)
                return self.aplicacion(environ, start_response)
            except BdbQuit:
                pass  # Return None implicitly
                self.debugger.quitting = 1

As you can see, it is basically a mix of Bdb.set_trace and Bdb.set_continue which we came up by trial and error.  If there was something like Bdb.runcall_no_prompt or an extra flag to Bdb.runcall to trigger this behaviour, this copy and paste would not be necessary.

components: Library (Lib)
messages: 234819
nosy: etanol
priority: normal
severity: normal
status: open
title: Add non-interactive version of Bdb.runcall
type: enhancement
versions: Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list