[PATCH] Python3 compatible tests and credentials module
pviktori at redhat.com
Fri Nov 25 15:40:20 UTC 2016
On 11/25/2016 03:40 AM, Andrew Bartlett wrote:
> On Thu, 2016-11-24 at 14:59 +0100, Lumir Balhar wrote:
>> Because I have no response for two weeks on GitHub , I decided to
>> send my patches here. Which way is preferred, please?
>>  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, 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.
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.
More information about the samba-technical