[PATCHES] Port pytalloc to Python 3

Petr Viktorin pviktori at redhat.com
Thu Nov 27 07:47:30 MST 2014

Hello! I'm Petr, and I'm helping Fedora move to Python 3.

I've seen a discussion on this list from May 2013 [0] with some kind of 
consensus that porting Samba is inevitable, and would be hard, but there 
was no rush. Some posts there cite a wiki page [1] that used to warn 
against moving prematurely, but now it says:
> Python 2.x is legacy, Python 3.x is the present and future of the language

I've chosen a smaller, self-contained library to start the porting work, 
and get some discussion about expectations of how porting all of Samba 
should eventually look like.
So far I'm new to Samba; happy to hear what I'm doing wrong!

I've asked about getting personal copyright assignment from Red Hat 
legal (I'm new to that part, too). Hopefully that will get sorted out 
before review is done. Please treat this patchset as a WIP for the time 

[0] https://lists.samba.org/archive/samba-technical/2013-May/092648.html
[1] https://wiki.python.org/moin/Python2orPython3

With these patches, pytalloc can be built for Python 3.
To build:
     cd lib/talloc
     PYTHON=/usr/bin/python3 ./configure
The rest of Samba should not be affected.
Note that Python 2 is still used to run waf itself.

The first patch makes it possible to build C extensions for Python 3. 
I'm not sure how much of a complete fork Samba's waf is – should I send 
this patch upstream somewhere?

The second patch is not strictly necessary (Python will load extensions 
without an ABI tag in the filename), but it's good practice.
I'm curious why pyext_PATTERN contains "%s" but string interpolation was 
not used with it?

The third patch is mostly your usual C extension porting (a lot of 
#ifdefs), aside from one  change that might be controversial: I removed 
pytalloc_CObject_FromTallocPtr without replacement. I did not see this 
function used much, and since code that needs it would have to be ported 
anyway, I decided to hold off making a PyCapsule version until it's 
clear that it's actually needed.

On most systems, Python 2 and 3 will coexist. To support this, the 
fourth patch renames pytalloc.o to py3talloc.o under Python 3, and does 
the same with the pkg-config file.

Thanks for your time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-buildtools-Honor-LDVERSION-when-looking-for-Python-l.patch
Type: text/x-patch
Size: 2970 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141127/dfe77313/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-buildtools-Use-all-of-pyext_PATTERN-in-map_shlib_ext.patch
Type: text/x-patch
Size: 1226 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141127/dfe77313/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-pytalloc-Port-to-Python-3.patch
Type: text/x-patch
Size: 7106 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141127/dfe77313/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-pytalloc-Build-pytalloc.o-as-py3talloc.o-under-Pytho.patch
Type: text/x-patch
Size: 3852 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141127/dfe77313/attachment-0003.bin>

More information about the samba-technical mailing list