[Python-Dev] PEP 409 and the stdlib
Ethan Furman
ethan at stoneleaf.us
Thu May 23 16:24:48 CEST 2013
On 05/23/2013 04:36 AM, "Martin v. Löwis" wrote:
> Am 21.05.13 18:03, schrieb Ethan Furman:
>> And, of course, we only make these changes when we're already modifying
>> the module for some other reason.
>
> In the specific case, the KeyError has indeed useful information that
> the TypeError does not, namely the specific character that is the culprit.
>
> So if you do drop the KeyError entirely, please carry over information
> about the character into the TypeError.
Here's the code that existed at one point:
for c in s:
val = _b32rev.get(c)
if val is None:
raise TypeError('Non-base32 digit found')
Even though there is no KeyError to convert in this incarnation, providing the cause of failure is still appreciated by
the user who's trying to figure out what, exactly, went wrong.
--
~Ethan~
More information about the Python-Dev
mailing list