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 | 45cb1fed490d1fdafc5b63f2f5a33dfe5b334972 (patch) | |
tree | 59c625cdb44333f9f8a227dff6cfcb1bc82cd5ca /source/python/py_common.c | |
parent | 4114fe5996f84dfd14855ffdf666e065446607b4 (diff) | |
download | samba-45cb1fed490d1fdafc5b63f2f5a33dfe5b334972.tar.gz samba-45cb1fed490d1fdafc5b63f2f5a33dfe5b334972.tar.xz samba-45cb1fed490d1fdafc5b63f2f5a33dfe5b334972.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.
Diffstat (limited to 'source/python/py_common.c')
-rw-r--r-- | source/python/py_common.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/source/python/py_common.c b/source/python/py_common.c index 019bcca07c8..5b80f09498c 100644 --- a/source/python/py_common.c +++ b/source/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; } |