[issue1997] unicode and string compare should not cause an exception

Aaron Watters report at bugs.python.org
Sat Feb 2 16:00:54 CET 2008


Aaron Watters added the comment:

Okay.  I haven't looked but this should be well documented
somewhere because I found it very surprising (it crashed a large
run somewhere in the middle).

In the case of strings versus unicode I think it is possible
to hack around this by catching the exceptional case and
comparing character by character -- treating out of band
characters as larger than all unicode characters.  I don't
see why this would cause any problems at any rate.

   -- Aaron Watters

On Feb 1, 2008 6:47 PM, Guido van Rossum <report at bugs.python.org> wrote:

>
> Guido van Rossum added the comment:
>
> > As I understand it comparisons between two objects should
> > always work.
>
> Hi Aaron!  Glad to see you're back.
>
> It used to be that way when you & Jim wrote the first Python book. :-)
>
> Nowadays, comparisons *can* raise exceptions.  Marc-Andre has explained
> why.  In 3.0, this particular issue will go away due to a different
> treatment of Unicode, but many more cases will raise TypeError when < is
> used.  == and != will generally work, though there are no absolute
> guarantees.
>
> ----------
> nosy: +gvanrossum
> resolution:  -> rejected
> status: open -> closed
>
> __________________________________
> Tracker <report at bugs.python.org>
> <http://bugs.python.org/issue1997>
> __________________________________
>

Added file: http://bugs.python.org/file9348/unnamed

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1997>
__________________________________
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: unnamed
Url: http://mail.python.org/pipermail/python-bugs-list/attachments/20080202/284eeb3c/attachment.txt 


More information about the Python-bugs-list mailing list