A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-July/006621.html below:

[Python-Dev] decoding errors when comparing strings

[Python-Dev] decoding errors when comparing strings [Python-Dev] decoding errors when comparing stringsM.-A. Lemburg mal@lemburg.com
Sat, 15 Jul 2000 19:59:56 +0200
"M.-A. Lemburg" wrote:
> 
> BTW, I have a feeling that we should mask the decoding errors
> during compares in favour of returning 0...
> 
> ...otherwise the current dictionary would bomb (it doesn't do any
> compare error checking !) in case a Unicode string happens to have
> the same hash value as an 8-bit string key. (Can't test this right now,
> but this is what should happen according to the C sources.)

Here's the test:

>>> s = 'ä'
>>> u = u'ä'
>>> hash(s)
-880683291
>>> hash(u)
-880683291
>>> d = {s:1}
>>> d[s]
1
>>> d[u]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
KeyError>>> 
>>> 

Looks strange, doesn't it...

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4