[issue29021] Custom functions in sqlite receive None on invalid UTF-8

Aviv Palivoda report at bugs.python.org
Wed Jan 4 17:07:23 EST 2017


Aviv Palivoda added the comment:

The problem is in _pysqlite_build_py_params function at connection.c. In case we have text we do the following code:

case SQLITE_TEXT:
      val_str = (const char*)sqlite3_value_text(cur_value);
      cur_py_value = PyUnicode_FromString(val_str);
      /* TODO: have a way to show errors here */
      if (!cur_py_value) {
             PyErr_Clear();
             Py_INCREF(Py_None);
             cur_py_value = Py_None;
      }
      break;

As you can see we call PyUnicode_FromString instead of text_factory.

I started making a patch to fix this by passing the text_factory to _pysqlite_build_py_params function but I currently have a problem with setting the result to the sqlite. User text_factory may return any type of object and I can't see how to handle that...

----------
nosy: +palaviv

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29021>
_______________________________________


More information about the Python-bugs-list mailing list