New submission from Anthony Sottile <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue41767>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com