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 methane
Recipients ezio.melotti, methane, r.david.murray, serhiy.storchaka, vstinner
Date 2015-08-19.08:12:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439971946.13.0.865557814401.issue24870@psf.upfronthosting.co.za>
In-reply-to
Content
> Why are bytes being escaped in a binary blob? The reason to use surrogateescape is when you have data that is mostly text, should be processed as text, but can have occasional binary data.  That wouldn't seem to apply to a database binary blob.

Since SQL may contain binary data.

data = bytes(range(256))
cursor.execute(u"INSERT INTO t (blob_col) values (%(data)s)", {"data": data})

DB driver should escape properly for SQL syntax, then decode with surrogateescape for % operator.

bytes in Python 3.5 supports % operator so I can use it instead of unicode %.
But I'll continue to support Python 3.4 for some years.
History
Date User Action Args
2015-08-19 08:12:26methanesetrecipients: + methane, vstinner, ezio.melotti, r.david.murray, serhiy.storchaka
2015-08-19 08:12:26methanesetmessageid: <1439971946.13.0.865557814401.issue24870@psf.upfronthosting.co.za>
2015-08-19 08:12:26methanelinkissue24870 messages
2015-08-19 08:12:25methanecreate