python: Add compatability helpers to determine if type is really bytes
authorNoel Power <noel.power@suse.com>
Wed, 7 Mar 2018 14:39:54 +0000 (14:39 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 23 Mar 2018 06:28:25 +0000 (07:28 +0100)
commitaea433ee0c87d42f670aa8b9e068b80cf2d9ef09
tree444b4cf2896c886c09a98877757cc3178dd0ef5a
parent0d65c1ef65b1485ae772ac87a52bb58611d45c72
python: Add compatability helpers to determine if type is really bytes

py3compat has PyBytes_Check macro which evalates to PyString_Check in
python2. To help switch behaviour based on whether you are dealing
with the bytes type the following macros have been added.

IsPy3Bytes
IsPy3BytesOrString

IsPy3Bytes will evaluate to false in python2 and will return the
expected result in python3. IsPy3BytesOrString will test for string
type alone in python2 or bytes and string in python3.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/py3compat.h