[issue2651] Strings passed to KeyError do not round trip

Anthony Sottile report at bugs.python.org
Fri Sep 11 22:12:36 EDT 2020


Anthony Sottile <asottile at umich.edu> added the comment:

(I know this is old and closed but I've just run into the same thing with pwd.getpwnam in issue41767)


KeyError: "getpwnam(): name not found: 'test'"


would it be possible / make sense to extend `KeyError` with a named-only-argument which would preserve the raw string in this case?

something like (yeah the name is probably not great, I haven't had time to think much about this)

raise KeyError("getpwnam(): name not found 'test'", preserve_msg=True)

----------
nosy: +Anthony Sottile

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue2651>
_______________________________________


More information about the Python-bugs-list mailing list