[issue26389] Expand traceback module API to accept just an exception as an argument
Martin Panter
report at bugs.python.org
Mon Feb 27 02:31:36 EST 2017
Martin Panter added the comment:
Matthias’s proposal adds support for a new keyword-only “exc” argument:
print_exception(exc=exception_instance)
I still think it is worth supporting a single positional argument as well:
print_exception(exception_instance)
Another point is that it may be better to keep the existing parameter name “value”, rather than (eventually?) replacing it with “exc”. I think both of these things could be accomplished by juggling the “value” and “etype” parameters:
def print_exception(etype=None, value=None, tb=None, ...):
if value is None: # Assume value passed as first positional argument
value = etype
etype = None
if etype is tb is None: # Only value passed
etype = type(value)
tb = value.__traceback__
# Existing code using (etype, value, tb)
The disadvantage of any of these changes is that we may want to maintain support for the old signature while Python 2 remains alive.
----------
stage: test needed -> patch review
versions: +Python 3.7 -Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26389>
_______________________________________
More information about the Python-bugs-list
mailing list