diff options
author | Tim Potter <tpot@samba.org> | 2002-04-14 23:39:02 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-04-14 23:39:02 +0000 |
commit | 0c01601d31c401bc17747f91e72db82cd7454266 (patch) | |
tree | 420d5a9436c95f28e13d4cab3c6e45058f634f90 | |
parent | f6da697708576f4ff3be0b3da5b7271754cbc1ef (diff) | |
download | samba-0c01601d31c401bc17747f91e72db82cd7454266.tar.gz samba-0c01601d31c401bc17747f91e72db82cd7454266.tar.bz2 samba-0c01601d31c401bc17747f91e72db82cd7454266.zip |
Explicitly return a list in py_ntstatus_tuple() and py_werror_typle(). Not
sure whether these should really be tuples or lists.
In open_pipe_creds() raise PyExc_RuntimeError exceptions if the pipe
connect function returns an error.
(This used to be commit 45cb1fed490d1fdafc5b63f2f5a33dfe5b334972)
-rw-r--r-- | source3/python/py_common.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/source3/python/py_common.c b/source3/python/py_common.c index 019bcca07c..5b80f09498 100644 --- a/source3/python/py_common.c +++ b/source3/python/py_common.c @@ -27,7 +27,7 @@ PyObject *py_werror_tuple(WERROR werror) { - return Py_BuildValue("is", W_ERROR_V(werror), + return Py_BuildValue("[is]", W_ERROR_V(werror), dos_errstr(werror)); } @@ -35,7 +35,7 @@ PyObject *py_werror_tuple(WERROR werror) PyObject *py_ntstatus_tuple(NTSTATUS ntstatus) { - return Py_BuildValue("is", NT_STATUS_V(ntstatus), + return Py_BuildValue("[is]", NT_STATUS_V(ntstatus), nt_errstr(ntstatus)); } @@ -189,7 +189,24 @@ struct cli_state *open_pipe_creds(char *system_name, PyObject *creds, /* Now try to connect */ - connect_fn(cli, system_name, &nt_creds); + if (!connect_fn(cli, system_name, &nt_creds)) { + if (cli) { + NTSTATUS error = cli_nt_error(cli); + + /* Raise an exception if something went wrong. + FIXME: This should be a more appropriate + exception than PyExc_RuntimeError */ + + if (!NT_STATUS_IS_OK(error)) + PyErr_SetObject(PyExc_RuntimeError, + py_ntstatus_tuple(error)); + else + PyErr_SetString(PyExc_RuntimeError, + "error connecting to pipe"); + } + + return NULL; + } return cli; } |