On Wed, 28 Oct 2009, David Malcolm wrote:

On Mon, 2009-10-19 at 14:19 +0300, Panu Matilainen wrote:
On Thu, 15 Oct 2009, David Malcolm wrote:

Introduce macros and conditional compilation to deal with the major
changes to the way that Python extension modules are initialized between
Python 2 and 3 (PEP 3121).

Hmm, this is starting to look a bit more painful :)

[snip discussion of shared module state]

I didn't try out what it'd actually look like, but it'd seem to me that
the module initialization version differences could be made more obvious
(less #ifdefs) by splitting out much of the init work into a separate
function, ie something like
[snip]

I finally had a go at doing this; see the attached patch.

This patch splits each of the two modules' initialization into two
parts:
 - a "prepareInitModule" function that's called _before_ trying to get
a PyObject module pointer,
 - a "initModule" function that does the work upon a PyObject module
ptr.
giving four new functions in all; all of these functions return 1 for
success, 0 for failure.

These functions embed the commonality between 2 and 3 for module
initialization.

The 2 vs 3 differences are then reduced to calling out to each function
from 2 and 3-specific blocks of code.

Okay this looks much nicer at least to my eyes. Applied, thanks!

        - Panu -
_______________________________________________
Rpm-maint mailing list
[email protected]
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to