[New-bugs-announce] [issue38185] Weird way of case-insensitive indexing of sqlite3.Row

Serhiy Storchaka report at bugs.python.org
Mon Sep 16 06:00:11 EDT 2019


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

sqlite3.Row can be indexed by integers and by strings. In the latter case string matching is case insensitive. But the code that implements this is too simple-minded. It compares UTF-8 representation of two strings ignoring some bit. It works for ASCII letters, but has weird behavior for digits, '_' and non-ASCII characters.

For example:

>>> import sqlite3
>>> con = sqlite3.connect(":memory:")
>>> con.row_factory = sqlite3.Row
>>> row = con.execute("select 1 as a_1").fetchone()
>>> row['a_1']
1
>>> row['A_1']
1
>>> row['A_\x11']
1
>>> row['A\x7f1']
1
>>> row = con.execute("select 1 as ÿ").fetchone()
>>> row["ÿ"]
1
>>> row["Ÿ"]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: No item with that key
>>> row["ß"]
1

----------
components: Library (Lib)
messages: 352533
nosy: berker.peksag, ghaering, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Weird way of case-insensitive indexing of sqlite3.Row
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38185>
_______________________________________


More information about the New-bugs-announce mailing list