[New-bugs-announce] [issue41767] KeyError exception is more difficult to read due to quoting
Anthony Sottile
report at bugs.python.org
Fri Sep 11 20:17:04 EDT 2020
New submission from Anthony Sottile <asottile at umich.edu>:
For example:
>>> import pwd
>>> pwd.getpwnam("test")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: "getpwnam(): name not found: 'test'"
An improvement would be something which doesn't have the extra set of quotes such as:
>>> import pwd
>>> pwd.getpwnam("test")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: getpwnam(): name not found: 'test'
I understand this is due to the `KeyError` repr, I wonder if something could be done to improve this (maybe a subclass of KeyError? maybe a new optional named-only argument to KeyError?)
Seems there are others which could be improved here as well:
>>> import unicodedata
>>> unicodedata.lookup('zzz')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: "undefined character name 'zzz'"
----------
messages: 376754
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: KeyError exception is more difficult to read due to quoting
versions: Python 3.10, Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41767>
_______________________________________
More information about the New-bugs-announce
mailing list