[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at samba.org
Sun Apr 1 16:39:44 MDT 2012


Hi Richard,

Am 01/04/12 21:20, schrieb Richard Sharpe:
>         spdata = self->ptr;
>
> +       mem_ctx = talloc_new(NULL);
You probably want to check for mem_ctx == NULL here, perhaps:

if (mem_ctx == NULL) {
PyErr_NoMemory();
return NULL;
}
> +
>         io.generic.level = RAW_OPEN_NTCREATEX;
>         io.ntcreatex.in.root_fid.fnum = 0;
>         io.ntcreatex.in.flags = 0;
> @@ -479,7 +473,9 @@ static PyObject *py_open_file(pytalloc_Object *self, PyObjec
>         io.ntcreatex.in.security_flags = 0;
>         io.ntcreatex.in.fname = filename;
>
> -       status = smb_raw_open(spdata->tree, self->talloc_ctx, &io);
> +       status = smb_raw_open(spdata->tree, mem_ctx, &io);
> +       talloc_free(mem_ctx);
> +
>         PyErr_NTSTATUS_IS_ERR_RAISE(status);
>
>         fnum = io.ntcreatex.out.file.fnum;
> @@ -541,7 +537,7 @@ static PyMethodDef py_smb_methods[] = {
>                 Set security descriptor for file." },
>         { "open_file", (PyCFunction)py_open_file, METH_VARARGS,
>                 "open_file(path, access_mask[, share_access[, open_disposition[,
> -               Open a file. Throws exceptions on errors." },
> +               Open a file. Throws NTSTATUS exceptions on errors." },
This isn't quite true - if you specify arguments of the wrong type, it
will raise TypeError for example. PyErr_NTSTATUS_IS_ERR_RAISE only
really guarantees that *a* exception is raised. At the moment that's a
RuntimeError but it might change in the future.

Sorry if I was a bit vague earlier - it's mostly useful to mention that
e.g. a NoSuchFile exception is raised if the requested file was not
found. At the moment I don't think we really any special cases like that.

Cheers,

Jelmer

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20120402/8845c69a/attachment.pgp>


More information about the samba-technical mailing list