New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sqlite3] Fix sqlite3_value_blob() usage #87462
Comments
The sqlite3_value_() API is almost identical to the sqlite3_column_() API. sqlite3_value_bytes() should be called after we've converted the value using sqlite3_value_blob(). See also bpo-43249. |
Related: If not, we should initialise cur_py_value to None, because as the PyBytes_FromStringAndSize docs says: "If v is NULL, the contents of the bytes object are uninitialized." |
This also applies to sqlite3_value_text(). It also applies to sqlite3_value_bytes() if a conversion takes place. We don't need to care about that as long as we call sqlite3_value_bytes() after conversion. Also, PyTuple_SetItem() errors are not checked. I would also suggest using PyUnicode_FromStringAndSize() iso. PyUnicode_FromString() in case SQLITE_TEXT, to avoid the unneeded strlen(). After sqlite3_value_text() is called, we can just use sqlite3_value_bytes(), since the length is precomputed as a result of the conversion. Berker, would you allow a PR to improve all these issues in _pysqlite_build_py_params(), or would you prefer them split up in multiple PR's? |
Thanks, Berker! I'll add separate issues for sqlite3_value_text() and the missing PyTuple_SetItem() error checks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: