INADA Naoki added the comment: > 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24870> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com