This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ferferga
Recipients ferferga
Date 2020-04-02.12:23:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
Hello. I think that I found a bug in how sqlite3 module handle bytes.

The connect function of sqlite3 accepts strings, FilePath objects and bytes. However, it's impossible for me to connect to bytes objects that are read from BufferedReaders. I always get: 

"ValueError: embedded null byte"

This is my current code (byteDec is the BytesIO object):

==============================================
byteDec.seek(0)
conn = sqlite3.connect(byteDec.read())
==============================================

That returns the "embedded null byte" error. However, if I do:

==============================================
byteDec.seek(0)
with open("db.db", "wb" as f:
    f.write(byteDec.read())
conn = sqlite3.connect("db.db")
==============================================

Everything works flawlessly, so the BufferedReader that I have in-memory is not corrupted in any way, as it's readable from a file. I want to avoid writing to disk at all, so this is not a solution for me.


I attach to this issue a very basic proof of concept to understand the issue.

I'm running Pyhton 3.8.2 amd64 on Windows 10 1909
History
Date User Action Args
2020-04-02 12:23:03ferfergasetrecipients: + ferferga
2020-04-02 12:23:03ferfergasetmessageid: <[email protected]>
2020-04-02 12:23:03ferfergalinkissue40154 messages
2020-04-02 12:23:03ferfergacreate