]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
pybind: Use basestring as string type for Python 2
authorDavid Coles <dcoles@gaikai.com>
Mon, 19 Oct 2015 21:07:15 +0000 (14:07 -0700)
committerDavid Coles <dcoles@gaikai.com>
Mon, 19 Oct 2015 22:07:16 +0000 (15:07 -0700)
commit904c0e950ab1e903c560339cdb1f74ed1b863dad
treeb4262b30c2bf6f21b1793979f6545eb5fd36414f
parentab6b92398071a5e364514afe2bdb57a634c04ceb
pybind: Use basestring as string type for Python 2

Python 2's built-in string type is an 8-bit string, thus does not specify any
particular encoding representation (str and bytes are synonymous).
On the other hand, Python 3 strings are always Unicode strings and thus require
some form of encoding before they can be passed to char* based C APIs.

Because we now explicitly encode and decode strings used in C APIs, functions
that return "strings" will now return a Unicode string. To allow these values
to be safely round-tripped in Python 2, we must allow use of both Unicode
and 8-bit strings as "string" arguments. In Python 3, the Unicode str type is
used instead.

8-bit strings will be assumed to be using Python's default ASCII encoding,
while Unicode strings can accept any encodable string value.

Signed-off-by: David Coles <dcoles@gaikai.com>
src/pybind/rados.py
src/pybind/rbd.py