summaryrefslogtreecommitdiff
path: root/auth
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2019-07-06 19:09:57 +1200
committerAndrew Bartlett <abartlet@samba.org>2019-07-22 22:20:26 +0000
commit0d0a88fc6a4371bf3666186792f253cacf2f1378 (patch)
tree73fbc814bc801d337d71fb7d1d59fe1b35828947 /auth
parentc9c1d444881d4464842cfc19fcb5ddd41c58dfa9 (diff)
downloadsamba-0d0a88fc6a4371bf3666186792f253cacf2f1378.tar.gz
pycredentials.h: use import to ensure python type correctness
Because we include pyrpc_util.h, pycredentials doesn't need its own PyStringFromStringOrNull(). Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'auth')
-rw-r--r--auth/credentials/pycredentials.c7
-rw-r--r--auth/credentials/pycredentials.h15
2 files changed, 12 insertions, 10 deletions
diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c
index 9e231b04cb3..5002bb86e1c 100644
--- a/auth/credentials/pycredentials.c
+++ b/auth/credentials/pycredentials.c
@@ -37,13 +37,6 @@
void initcredentials(void);
-static PyObject *PyString_FromStringOrNULL(const char *str)
-{
- if (str == NULL)
- Py_RETURN_NONE;
- return PyUnicode_FromString(str);
-}
-
static PyObject *py_creds_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
return pytalloc_steal(type, cli_credentials_init(NULL));
diff --git a/auth/credentials/pycredentials.h b/auth/credentials/pycredentials.h
index a136a210da3..bf6962c312b 100644
--- a/auth/credentials/pycredentials.h
+++ b/auth/credentials/pycredentials.h
@@ -20,12 +20,21 @@
#define _PYCREDENTIALS_H_
#include "auth/credentials/credentials.h"
+#include "librpc/rpc/pyrpc_util.h"
#include <pytalloc.h>
extern PyTypeObject PyCredentials;
extern PyTypeObject PyCredentialCacheContainer;
-#define PyCredentials_Check(py_obj) PyObject_TypeCheck(py_obj, &PyCredentials)
-#define PyCredentials_AsCliCredentials(py_obj) pytalloc_get_type(py_obj, struct cli_credentials)
-#define cli_credentials_from_py_object(py_obj) (py_obj == Py_None)?cli_credentials_init_anon(NULL):PyCredentials_AsCliCredentials(py_obj)
+#define PyCredentials_Check(py_obj) \
+ py_check_dcerpc_type(py_obj, "samba.credentials", "Credentials")
+
+#define PyCredentials_AsCliCredentials(py_obj) \
+ (PyCredentials_Check(py_obj) ? \
+ pytalloc_get_type(py_obj, struct cli_credentials) : NULL)
+
+#define cli_credentials_from_py_object(py_obj) \
+ ((py_obj == Py_None) ? \
+ cli_credentials_init_anon(NULL) : \
+ PyCredentials_AsCliCredentials(py_obj))
#endif /* _PYCREDENTIALS_H_ */