On Thu, Jul 6, 2017 at 5:58 AM, Paul Moore <[email protected]> wrote:
> To use the (already
>
over-used) NameError example, Ken's proposal doesn't include any
> change to how NameError exceptions are raised to store the name
> separately on the exception.
>
Maybe I'm misunderstanding you, but the proposal has a clear example of
raising NameError and getting the name attribute from the exception
instance:
try:
raise NameError(name=name, template="name '{name}' is not defined.")
except NameError as e:
name = e.kwargs['name']
msg = str(e)
...
Yes. Because he tries to extract the name component of a NameError,
>
and yet that component isn't stored anywhere - under his proposal or
> under current CPython.
>
I'm not sure what you mean by "extract", but the proposal calls for the
name to be passed as a keyword argument (see above) and stored in
self.kwargs:
class BaseException:
def __init__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
I think this code does what you're asking it to do, right?
(N.B. BaseException is written in C, so this Python code is presumably
illustrative, not an actual implementation.)
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/