Message274860
No, the suggestion is to only adopt the first part of the patch from 2010, which is to revert KeyError to behave like LookupError again:
>>> print(LookupError('key'))
key
>>> print(KeyError('key'), 'now')
'key' now
>>> print(KeyError('key'), 'in 3.6')
key in 3.6
In other words, there is no descriptive message while stringifying KeyError. Having an API with two arguments was disruptive because it moved the key from e.args[0] to e.args[1].
Raymond, would it be acceptable to create a two-argument form where the *second* argument is the message? That way we could make descriptive error messages for dicts, sets, etc. possible. In this world:
>>> print(KeyError('key', 'key {!r} not found in dict'), 'in 3.6')
key 'key' not found in dict in 3.6
Do you think any code depends on `str(e) == str(e.args[0])`? |
|
Date |
User |
Action |
Args |
2016-09-07 18:29:49 | lukasz.langa | set | recipients:
+ lukasz.langa, rhettinger, amaury.forgeotdarc, belopolsky, pitrou, rharris, eric.araujo, vencabot_teppoo, Julian, martin.panter |
2016-09-07 18:29:49 | lukasz.langa | set | messageid: <1473272989.04.0.313182186216.issue2651@psf.upfronthosting.co.za> |
2016-09-07 18:29:49 | lukasz.langa | link | issue2651 messages |
2016-09-07 18:29:48 | lukasz.langa | create | |
|