Message293185
| Author |
martin.panter |
| Recipients |
Mariatta, martin.panter, rhettinger, serhiy.storchaka, wolma |
| Date |
2017年05月07日.09:29:04 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1494149344.94.0.867219791133.issue30097@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
This proposal would be useful. My use case is for when an API suppresses an external exception context:
>>> import os
>>> try:
... os.environ["NEW_VARIABLE"] = bug # Hidden exception
... finally:
... del os.environ["NEW_VARIABLE"] # KeyError
...
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/usr/lib/python3.5/os.py", line 699, in __delitem__
raise KeyError(key) from None
KeyError: 'NEW_VARIABLE'
This feels like a step backwards to Python 2, and enabling the full backtrace would make this easier to analyze:
>>> try:
... os.environ["NEW_VARIABLE"] = bug # TypeError
... finally:
... del dict()["NEW_VARIABLE"] # KeyError
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/lib/python3.5/os.py", line 688, in __setitem__
value = self.encodevalue(value)
File "/usr/lib/python3.5/os.py", line 756, in encode
raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
KeyError: 'NEW_VARIABLE' |
|