Carl Meyer <c...@oddbird.net> added the comment:

Awkwardly, the motivating use case in issue21145 is a TypeError that we wanted 
to raise within __set_name__, and not have replaced. It feels a little ugly to 
special case TypeError this way. 

I like the _PyErr_TrySetFromCause idea. That function is a bit ugly too, in the 
way it has to try and sniff out whether an exception has extra state or is safe 
to copy and add extra context to. But in practice I think the results would be 
pretty good here. Most of the time you’d get the original exception but with 
added useful context; occasionally for some exception types you might just not 
get the extra context. But as long as TypeError falls in the former category it 
would help with the worst case. 

I’ll look at using that in the PR.

----------

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

Reply via email to