Xavier de Gaye added the comment:

This patch is an attempt at allowing the source debugging of scripts executed 
by the Python exec() function. It misses tests and documentation.

You may use it using the idiom given in the following example to avoid stepping 
into the pdb code on the first invocation of pdb.exec_script() (see the 
exec_script() doc string):

import sys

def main():
    foo = 123
    s = """if 1:
        x = foo
        x = 555
    """
    exec_script(s)

if __name__ == '__main__':
    if '--debug' in sys.argv[1:]:
        import pdb
        exec_script = pdb.exec_script
        pdb.Pdb(skip=['pdb']).set_trace()
    else:
        exec_script = exec

    main()

----------
components:  -Demos and Tools
keywords: +patch
stage:  -> needs patch
versions: +Python 3.7 -Python 3.5
Added file: http://bugs.python.org/file45366/debug_script.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28610>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to