[PATCH] Re: samba-tool fsmo transfer - uncaught exception
Alexander Bokovoy
ab at samba.org
Mon May 27 08:27:19 UTC 2019
On ma, 27 touko 2019, Rowland penny via samba-technical wrote:
> On 27/05/2019 02:28, Douglas Bagnall wrote:
> > On 26/05/19 11:22 PM, Rowland penny wrote:
> >
> > > How do you test for something that works on some computers, but not on
> > > others ?
> > With Gitlab CI.
> >
> > > Which is correct, it working, or it not working ?
> > Well, when I go
> >
> > PYTHONPATH=bin/python python3 -c 'import samba; samba.drs_utils.drsException'
> >
> > I get "module 'samba' has no attribute 'drs_utils'".
> >
> > Maybe Python 2 was different.
> >
> > > If you have a problem with the test, take it up with Andrew, I initially
> > > created the script following his advice, he later 'improved' it, obviously
> > > not enough ;-)
> > Yes. It only tests 'samba-tool fsmo show', not 'seize' and 'transfer'.
> That is what Andrew wanted at the time, feel free to extend the test.
> >
> > > Anyway, NACK to your patch, but only because you haven't remove the
> > > 'import samba' line.
> > OK, though I don't it would work with the line removed.
> > For example, it would break
> >
> > forest_dn = samba.dn_from_dns_name(samdb.forest_dns_name())
> >
> > and it *might* break other things too because, as discussed, Python
> > imports can be a bit weird with unexpected side-effects.
> >
> > cheers,
> > Douglas
>
> So how do you propose to test for this ? When having just 'import samba'
> fails for 'samba.drs_utils' but works for 'samba.dn_from_dns_name' ? To me,
> this looks like a bug in python.
https://docs.python.org/3/reference/import.html is the canonical
documentation on how module import works. When you do 'import samba',
you are importing samba/__init__.py implicitly. That file defines what
is in the 'samba' namespace as imported. It has no references to
'drs_utils' so the only ways to get 'samba.drs_utils' is to do 'from
samba import drs_utils' or 'import samba.drs_utils' explicitly -- in the
former case we'll get drs_utils directly, in the latter --
samba.drs_utils.
--
/ Alexander Bokovoy
More information about the samba-technical
mailing list