[PATCH] Python3 compatible tests and credentials module
Andrew Bartlett
abartlet at samba.org
Fri Nov 25 20:24:30 UTC 2016
On Fri, 2016-11-25 at 16:40 +0100, Petr Viktorin wrote:
> On 11/25/2016 03:40 AM, Andrew Bartlett wrote:
> >
> > On Thu, 2016-11-24 at 14:59 +0100, Lumir Balhar wrote:
> > >
> > > Hello.
> > >
> > > Because I have no response for two weeks on GitHub [0], I decided
> > > to
> > > send my patches here. Which way is preferred, please?
> ...
> >
> > >
> > > [0] https://github.com/samba-team/samba/pull/68
> >
> > Thanks for the patch. The main thing I don't like is the if PY3
> > stuff,
> > and the .args usage. I would rather we ported param and glue to
> > python3 at the same time, they shouldn't be too hard.
> >
> > Please use
> >
> > (enum, estr) = e
> >
> > rather than
> >
> > enum = e.args[0], or better still help us find a way to have
> > LdbError
> > (and the other error exceptions) return an object we can both de-
> > construct in this way, as well as something more friendly like
> > e.enum.
>
>
> Hi,
> In Python 3, exceptions don't behave as sequences of their
> arguments;
> they only provide a tuple (i.e. the object you can deconstruct) as
> "args". Would this be acceptable?
>
> (enum, estr) = e.args
>
>
> Adding custom behavior to exceptions is possible by subclassing
> PyExc_Exception instead of using the PyErr_NewException helper. So
> you
> could say both `(enum, estr) = e` and `e.enum, e.estr`. The
> disadvantages are that iterable exception is non-standard in Python
> 3,
> and that subclassing in C involves a lot of boilerplate.
I'm keen that we stay as close to standard python3 as possible, but I
was hoping that our exceptions could move from unnamed tuples to
something names, so we didn't just have to know by pattern that the
first element is the number, the second the name etc.
So
(enum, estr) = e.args
would be OK, I suppose, but I really want
enum = e.enum
estr = e.estr
That way we can extended NTSTATUSError to include numeric, string and
friendly (english) error messages, for example.
I'm also a little surprised this didn't come up when ldb was converted.
What happened there? Am I right that none of our ldb tests actually
check error codes?
Thanks,
Andrew Bartlett
--
Andrew Bartlett http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Catalyst IT http://catalyst.net.nz/services/samba
More information about the samba-technical
mailing list