summaryrefslogtreecommitdiff
path: root/python/py3compat.h
AgeCommit message (Collapse)AuthorFilesLines
2023-11-20Use python.h from libreplaceAndreas Schneider1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-17py3compat: remove obsolete commentsDouglas Bagnall1-16/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-17py bindings: write 'bytes', not 'PY_DESC_PY3_BYTES'Douglas Bagnall1-2/+0
Because it is shorter, clearer, and reduces py3compat.h Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-23py3: Remove #define IsPy3BytesOrString(pystr)Andrew Bartlett1-11/+0
This was (PyUnicode_Check(pystr) || PyBytes_Check(pystr)) This allows us to end the use of Python 2/3 compatability macros. The one caller will be simplified in the next commit Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <nopower@samba.org>
2020-03-23py3: Remove #define IsPy3Bytes PyBytes_CheckAndrew Bartlett1-2/+0
This allows us to end the use of Python 2/3 compatability macros. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2020-03-23py3: Remove #define PyInt_FromLong PyLong_FromLongAndrew Bartlett1-6/+0
This allows us to end the use of Python 2/3 compatability macros. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power
2020-03-23py3: Remove #define PyInt_AsLong PyLong_AsLongAndrew Bartlett1-1/+0
This allows us to end the use of Python 2/3 compatability macros. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2020-03-23py3: Remove #define PyInt_Type PyLong_TypeAndrew Bartlett1-1/+0
This allows us to end the use of Python 2/3 compatability macros. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2020-03-23py3: Remove #define PyInt_Check PyLong_CheckAndrew Bartlett1-1/+0
This will allow us to remove some unused code in the PIDL-generated python bindings. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2019-06-24py3: Remove PyStr_AsUTF8AndSize() compatability macroAndrew Bartlett1-2/+0
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24py3: Remove PyStr_AsUTF8() compatability macroAndrew Bartlett1-1/+0
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24py3: Remove PyStr_AsString() compatability macroAndrew Bartlett1-2/+0
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24py3: Remove PyStr_FromFormatV() compatability macroAndrew Bartlett1-1/+0
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24py3: Remove PyStr_FromFormat() compatability macroAndrew Bartlett1-1/+0
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24py3: Remove PyStr_FromStringAndSize() compatability macroAndrew Bartlett1-1/+0
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24py3: Remove PyStr_FromString() compatability macroAndrew Bartlett1-1/+0
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24py3: Remove PyStr_Check() compatability macroAndrew Bartlett1-2/+1
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24py3: Remove PyStr_Type() compatability macroAndrew Bartlett1-1/+0
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-06py3: Remove unused PyInt_AsSsize_t macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Jun 6 13:26:05 UTC 2019 on sn-devel-184
2019-06-06py3: Remove unused PyInt_AsUnsignedLongLongMask macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyInt_AS_LONG macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyInt_FromSize_t macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyInt_FromSsize_t macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyInt_FromString macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyInt_CheckExact macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PY_DESC_PY3_STRING macro from py3compat.hAndrew Bartlett1-2/+1
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyStr_AsUTF8String macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyStr_Decode macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyStr_InternFromString macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyStr_InternInPlace macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyStr_Format macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyStr_Concat macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused PyStr_CheckExact macro from py3compat.hAndrew Bartlett1-1/+0
Now that we are no longer developing new py2/py3 compatible code we can remove any aspects of this header we do not use. This will make the eventual removal easier. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove unused IS_PY3 macro from py3compat.hAndrew Bartlett1-4/+0
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-06-06py3: Remove Python2 side of py3compat.hAndrew Bartlett1-96/+0
This is unused as we do not support building python modules (etc) under py2. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2019-01-13python: Add new compat PYARG_STR_UNI formatNoel Power1-0/+10
In python2 PYARG_STR_UNI evaluates to et which allows str type (e.g bytes) pass through unencoded and accepts unicode objects encoded as utf8 In python3 PYARG_STR_UNI evaluates to es which allows str type encoded as named/specified encoding Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23python: Add compatability helpers to determine if type is really bytesNoel Power1-0/+24
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>
2018-03-01py3compat: add strings describing bytes/unicode in both versionsDouglas Bagnall1-0/+8
What Python 3 calls "bytes", Python 2 calls "string"; What Python 3 calls "string", Python 2 calls "unicode". This can cause confusion in e.g. help strings where the precise type matters. These macros can be used to construct accurate messages for both versions. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Thu Mar 1 04:36:15 CET 2018 on sn-devel-144
2017-05-19python3: Use "y#" instead of "s#" for binary data in PyArg_ParseTuplePetr Viktorin1-0/+8
The "s#" format code for PyArg_ParseTupleAndKeywords and Py_BuildValue converts a char* and size to/from Python str (with utf-8 encoding under Python 3). In some cases, we want bytes (str on Python 2, bytes on 3) instead. The code for this is "y#" in Python 3, but that is not available in 2. Introduce a PYARG_BYTES_LEN macro that expands to "s#" or "y#", and use that in: - credentials.get_ntlm_response (for input and output) - ndr_unpack argument in PIDL generated code Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-01python: Add py3compat.hPetr Viktorin1-0/+167
This adds a shared header file with macros that enable compatibility between Python 2 and 3. The macros are the ones used in ldb/tdb, with some additions that make sense when the header is shared among several modules. See the module for a summary of contents. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>