[DB-SIG] Should Binary accept unicode string?
mike_mp at zzzcomputing.com
Fri Jan 15 09:39:24 EST 2016
On 01/12/2016 07:59 AM, INADA Naoki wrote:
> Hi, all.
> I found DB-API 2.0 defines Binary() as Binary(string).
> What the string means?
> On Python 2, should Binary accept unicode?
> On Python 3, should Binary accept str?
IMO, Py2K's "binary" is str, that's all you should accept, and Py3K's
"binary" is "bytes", that's all you should accept. A Unicode object is
not a "binary" any more than a Python dictionary is. If your users are
looking for the "convenience" of assuming unicodes become binaries by
using the nearest available character set to encode it, they need to be
reminded of "explicit is better than implicit" :).
> INADA Naoki <songofacandy at gmail.com <mailto:songofacandy at gmail.com>>
> DB-SIG maillist - DB-SIG at python.org
More information about the DB-SIG