New submission from Erlend Egeberg Aasland <erlend.aasl...@innova.no>:

sqlite3_column_bytes() should be called _after_ sqlite3_column_blob(). There 
two calls to sqlite3_column_blob() are both preceeded by calls to 
sqlite3_column_bytes(). Currently it does not do any harm, but it is bad API 
usage.

I suggest to fix the two cases, and add a comment in the source code as a 
reminder.

Berker?


Quoting from https://sqlite.org/c3ref/column_blob.html:
The safest policy is to invoke these routines in one of the following ways:
  * sqlite3_column_text() followed by sqlite3_column_bytes()
  * sqlite3_column_blob() followed by sqlite3_column_bytes()
  * sqlite3_column_text16() followed by sqlite3_column_bytes16()

In other words, you should call sqlite3_column_text(), sqlite3_column_blob(), 
or sqlite3_column_text16() first to force the result into the desired format, 
then invoke sqlite3_column_bytes() or sqlite3_column_bytes16() to find the size 
of the result.

----------
components: Library (Lib)
messages: 387212
nosy: berker.peksag, erlendaasland, serhiy.storchaka
priority: normal
severity: normal
status: open
title: sqlite3_column_bytes() should be called after sqlite3_column_blob()
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43249>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to