python3: Use "y#" instead of "s#" for binary data in PyArg_ParseTuple
authorPetr Viktorin <pviktori@redhat.com>
Wed, 3 May 2017 14:57:07 +0000 (16:57 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 19 May 2017 20:20:15 +0000 (22:20 +0200)
commit40e409bf9e89a163c771b2a58493d2c1b496fae7
tree28dceee63f2a27ebcc7b5355d94bfed91b4975b9
parentb691f6d32f79ef8427f567612243dd51ea8d5584
python3: Use "y#" instead of "s#" for binary data in PyArg_ParseTuple

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>
auth/credentials/pycredentials.c
pidl/lib/Parse/Pidl/Samba4/Python.pm
python/py3compat.h