[issue20853] pdb "args" crashes when an arg is not printable

Xavier de Gaye report at bugs.python.org
Tue Mar 18 17:40:04 CET 2014


Xavier de Gaye added the comment:

> There is at least one other place (do_break) where this same problem could crop up.

Also in do_retval. And the exception is silently ignored in do_p and do_pp when repr() fails, which is not correct.

A solution could be to have a message_safe method to be used in such cases. For example, substitute in do_args:

    self.message('%s = %r' % (name, dict[name]))
with:
    self.message_safe('%s = %r', name, dict[name])

def message_safe(self, fmt, *args):
    try:
        print(fmt % args, file=self.stdout)
    except Exception:
        exc_info = sys.exc_info()[:2]
        self.error(traceback.format_exception_only(*exc_info)[-1].strip())

----------
nosy: +xdegaye

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20853>
_______________________________________


More information about the Python-bugs-list mailing list