[PATCH] Python3 compatible modules - credentials, param, _glue

Andrew Bartlett abartlet at samba.org
Fri Feb 10 18:30:33 UTC 2017


On Fri, 2017-02-10 at 15:21 +0100, Petr Viktorin wrote:
> On 02/09/2017 10:28 PM, Andrew Bartlett wrote:
> > On Thu, 2017-02-09 at 17:18 +0100, Stefan Metzmacher wrote:
> > > Hi Petr,
> > > 
> > > > > > > I've started a thread to have us move to just using
> > > > > > > PyCapsule
> > > > > > > by
> > > > > > > requiring 2.7.  I think this is likely to get up, but we
> > > > > > > will
> > > > > > > know
> > > > > > > soon.  This will kill a number of birds with one stone,
> > > > > > > so
> > > > > > > can you re-
> > > > > > > work the patches to rely on PyCapsule?
> > > > > > 
> > > > > > Requiring 2.7 is two questions in one:
> > > > > > - the minimum version for Samba
> > > > > > - the minimum version for independent libraries like
> > > > > > pytalloc
> > > > > > 
> > > > > > But thinking about this, I realized pytalloc can
> > > > > > - export pytalloc_CObject_FromTallocPtr for Python 2
> > > > > > - export pytalloc_PyCapsule_FromTallocPtr for Python 3
> > > > > > *and*
> > > > > > 2.7
> > > > > > 
> > > > > > Then Samba could use only PyCapsule (if it doesn't need 2.6
> > > > > > compatibility), while talloc maintains backwards
> > > > > > compatibility.
> > > > > 
> > > > > Maybe to naive, but can't we somehow simulate PyCapsule on
> > > > > top of
> > > > > CObject for 2.6?
> > > > > And use PyCapsule everywhere in the code?
> > > > 
> > > > That's roughly what the proposed patchset does -- it even
> > > > references the
> > > > comment below. It's possible, but not particularly pretty.
> > > 
> > > Why I had a brief look and everything but PyCapsule_Import()
> > > should
> > > be
> > > pretty easy
> > > to similate on top of PyCObject.
> > > 
> > > In the last patchset from Andrew I'm wondering why
> > > PyCapsulate_GetContext() is used,
> > > I'd guess PyCObject_GetDesc should be replaced by
> > > PyCapsule_GetName().
> > > 
> > > I don't think we actually need PyCapsulate_{Get,Set}Context() for
> > > our
> > > usage.
> > > PyCapsule_New() and PyCapsule_GetPointer() should be enough.
> > > I only used PyCObject_GetDesc() because PyCObject_AsVoidPtr()
> > > doesn't
> > > have
> > > a way to check the description.
> > 
> > I'm afraid this is all a little above my head right now.  I was
> > just
> > trying to un-wrap it, but clearly I need to read up on this area.
> > 
> > > Something like this should work and provide PyCapsulate
> > > for all samba callers even with python 2.6
> > 
> > I'm happy with whatever outcome you and Petr think is best, because
> > my
> > primary goal is to get this in to master, but my preference would
> > be to
> > actually expect Python from 2010 rather than still support Python
> > from
> > 2008.
> > 
> > In particular, I would really like to avoid unnecessary wrappers:
> > if we
> > have reason to expect we can write a wrapper, perhaps only add it
> > if we
> > get substantial negative feedback on the 2.7 requirement when Samba
> > 4.7
> > is released in September?
> 
> So as far as I see, it would be best to rework the patch to only use 
> PyCapsule (except pytalloc, which should provide constructors for
> both 
> Capsule and CObject). If it turns out PyCObject support is needed,
> it 
> can be added with a simple (but unsightly) set of macros/wrappers in
>> new commit, which would then also be easier to revert.

That sounds like a plan.  Ensure the pytalloc changes are also in a way
that makes it easy to rip out CObject if or when in the future I can
get consensus on that point.

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