[PATCH] add generated NTSTATUS error module for python

Alexander Bokovoy ab at samba.org
Mon Oct 10 09:25:25 UTC 2016


On ma, 10 loka 2016, Stefan Metzmacher wrote:
> Am 10.10.2016 um 04:12 schrieb Andrew Bartlett:
> > On Thu, 2016-10-06 at 15:19 -0700, Jeremy Allison wrote:
> >> On Fri, Sep 30, 2016 at 06:25:15AM +0200, Günther Deschner wrote:
> >>> Hi,
> >>>
> >>> please review and push.
> >>>
> >>> Thanks,
> >>> Guenther
> >>
> >> Hi Guenther, I'm still working on my python - but get:
> >>
> >> ../libcli/util/py_ntstatus.c:17:6: error: no previous prototype for
> >> ‘initntstatus’ [-Werror=missing-prototypes]
> >>  void initntstatus(void)
> >>
> >> when I try and build with this. Not sure where the
> >> missing proto should go...
> > 
> > Nowhere (or just above it, to shut up the warning).
> > 
> > Because this is essentially a plugin (to python), it is like our own
> > modules where the caller (python) works out the name and finds it with
> > dlopen/dlsym stuff, rather than via a header. 
> > 
> > The only thing I would ask for is some spaces in this:
> > +    print "writing new headerfile: %s"%pythonfile_name
> > +    out_file = open(pythonfile_name,"w")
> > 
> > eg
> > 
> > +    print "writing new headerfile: %s" % pythonfile_name
> > +    out_file = open(pythonfile_name, "w")
> > 
> > Sorry for the nitpick, but otherwise, it looks good to me, and we can
> > work from here to make some python exceptions so we can raise something
> > sensible when we need to return an NTSTATUS error from C.
> 
> Because of things like that and we may also want to have some functions
> translate from between NTSTATUS, WERROR and HRESULT, we may want to
> have a generic, samba.errors module that contains all of them.
> 
> So we may want to have a py_ntstatus_init(PyObject *m),
> py_werror_init(PyObject *m) and py_hresult_init(PyObject *m)
> which are called from a handwritten initerrors() function.
> 
> And I'd like to use a define instead of integer.
> 
> PyModule_AddObject(m, "NT_STATUS_SUCCESS",
> ndr_PyLong_FromUnsignedLongLong(0x00000000));
> 
> should be
> 
> PyModule_AddObject(m, "NT_STATUS_SUCCESS",
> 		   ndr_PyLong_FromUnsignedLongLong(NT_STATUS_V(NT_STATUS_SUCCESS)));
> 
> Or we use a define to make the lines shorter.
> 
> #define _ADD_CODE(m, v) do {\
> 	PyModule_AddObject(m, #v, \
> 		ndr_PyLong_FromUnsignedLongLong(NT_STATUS_V(v))); \
> } while(0)
Agreed. This is one area which made my life on FreeIPA side miserable
when tracking error codes. Having them unified is welcomed.

-- 
/ Alexander Bokovoy



More information about the samba-technical mailing list