[Python-Dev] Dict suppressing exceptions
M.-A. Lemburg
mal at egenix.com
Thu Aug 10 17:05:27 CEST 2006
Guido van Rossum wrote:
> On 8/10/06, M.-A. Lemburg <mal at egenix.com> wrote:
>> I'd suggest that we still inform the programmers of the problem
>> by issuing a warning (which they can then silence at will),
>> maybe a new PyExc_UnicodeWarning.
>
> Hmm... Here's an idea... How about we change unicode-vs-str __eq__ to
> issue a warning (and return False) instead of raising
> UnicodeException? That won't break much code (it's unlikely that
> people *depend* on this exception since it's generally a symptom of
> insane mixing of str and unicode). Then no further changes to
> dictobject.c are necessary (except fixing that one misleading
> comment).
Good idea.
>> Note that these exceptions help programmers making their applications
>> Unicode compatible, so silencing them completely would remove the
>> possibility to detect the case of mixing strings and Unicode as
>> keys in a dictionary.
>
> A warning would arguably have the same helping effect. (I suspect
> actually that we would have used warnings all along except we didn't
> have the warning framework when unicode was first introduced.)
Probably, yes.
These days, I believe that we should have not gone for the
string-Unicode integration magic at all and instead done the
same of what's planned for Py3k. Sometimes a clean cut is better
than trying to muddle along.
>> BTW, in Py3k, this case would not trigger at all, since all text
>> would be Unicode and bytes wouldn't be comparable to Unicode
>> anyway. However, that's a different discussion which we can have
>> after Python 2.5 is out the door.
>
> Which is why I said I would have gladly waited until Py3k to fix this.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Aug 10 2006)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Python-Dev
mailing list