[New-bugs-announce] [issue34052] sqlite's create_function() raises exception on unhashable callback, but creates function

Sergey Fedoseev report at bugs.python.org
Thu Jul 5 06:34:47 EDT 2018


New submission from Sergey Fedoseev <fedoseev.sergey at gmail.com>:

In [1]: import sqlite3

In [2]: con = sqlite3.connect(':memory:')

In [3]: con.execute('SELECT f()')
---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
<ipython-input-3-e3bab2096896> in <module>()
----> 1 con.execute('SELECT f()')

OperationalError: no such function: f

In [4]: con.create_function('f', 0, [])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-452e7d2028ac> in <module>()
----> 1 con.create_function('f', 0, [])

TypeError: unhashable type: 'list'

In [5]: con.execute('SELECT f()')
---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
<ipython-input-5-e3bab2096896> in <module>()
----> 1 con.execute('SELECT f()')

OperationalError: user-defined function raised exception


It seems that something like this cause segmentation fault, but I can't reproduce it.
Some other similar sqlite functions also affected. They can be easily modified to accept unhashable objects, but probably it should be done in another issue.

----------
components: Extension Modules
messages: 321094
nosy: sir-sigurd
priority: normal
severity: normal
status: open
title: sqlite's create_function() raises exception on unhashable callback, but creates function
type: behavior
versions: Python 2.7, Python 3.8

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


More information about the New-bugs-announce mailing list