Running into a problem with PyArg_ParseTuple ...

Andrew Bartlett abartlet at samba.org
Sun Mar 25 17:07:49 MDT 2012


On Sun, 2012-03-25 at 15:43 -0700, Richard Sharpe wrote:
> 2012/3/25 Richard Sharpe <realrichardsharpe at gmail.com>:
> > On Sun, Mar 25, 2012 at 2:15 PM, Jelmer Vernooij <jelmer at samba.org> wrote:
> >> On Sun, Mar 25, 2012 at 10:31:42AM -0700, Richard Sharpe wrote:
> >>> Hi folks,
> >>
> >>> I have tried to modify py_smb_getacl thusly:
> >>
> >>> -static PyObject *py_smb_getacl(pytalloc_Object *self, PyObject *args, PyObject
> >>> +static PyObject *py_smb_getacl(pytalloc_Object *self, PyObject *args)
> >>>  {
> >> ^^ What kind of change is this? It seems like the line isn't wrapped
> >> properly?
> >
> > It was a cut-n-paste issue. It compiles, otherwise I wouldn't get a crash :-)
> >
> >>>         NTSTATUS status;
> >>>         union smb_open io;
> >>>         union smb_fileinfo fio;
> >>>         struct smb_private_data *spdata;
> >>>         const char *filename;
> >>> +       int sinfo = 0;
> >>>         int fnum;
> >>
> >>> -       if (!PyArg_ParseTuple(args, "s:get_acl", &filename)) {
> >>> +       if (!PyArg_ParseTuple(args, "sl:get_acl", &filename, &sinfo)) {
> >>>                 return NULL;
> >>>         }
> >> You want "si" here rather than "sl" if sinfo is an "int".
> >
> > Well, it is an int, but l is for long int, which I might have
> > mistakenly thought was the same as int on ix86_64 and i686 ... maybe
> > not. I will give it a try to see if it resolves my problem.
> 
> Sigh. That was the problem.
> 
> I have a good short-term solution, however, I think that long-term
> those arguments need to be optional, because I suspect that there is
> working code out there using the current forms.

You can make them optional by putting them after a | in the format
string.

Andrew Bartlett

-- 
Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org



More information about the samba-technical mailing list