[PATCH 1 of 7] util: add a macro initializing CPython modules

Gregory Szorc gregory.szorc at gmail.com
Sat May 13 16:48:18 EDT 2017


On Sat, May 13, 2017 at 11:14 AM, Jun Wu <quark at fb.com> wrote:

> Excerpts from Yuya Nishihara's message of 2017-05-13 22:45:14 +0900:
> > I got lots of warnings because of the precheck/postinit expansion:
> >
> >   mercurial/util.h:80:16: warning: the comparison will always evaluate as
> >   'true' for the address of 'module_init' will never be NULL [-Waddress]
> >
> > > +            ((int (*)(PyObject *))postinit)(m); \
> >
> > It's dangerous to disable compiler type checking.
> >
> > Overall, I prefer not using a big macro like this even though it could
> get
> > rid of some redundant codes.
>
> This is mainly responding to Greg's comment about code duplication.
> Let me try if I can keep compiler type checking and remove those warnings.
>

FWIW, I've been thinking about merging the C modules into a single one. IMO
there aren't many benefits to having separate C modules other than clearer
naming. Having all the code in a single compilation unit facilitates more
code reuse, more aggressive compiler optimization, etc. It would get a
little weird on the pure Python / CFFI side of the world.


>
> If I can do that, I think the approach is still better - it avoids
> unintentional Py2 and Py3 inconsistence. For example, mpatchError is
> exposed
> in Py3, but not Py2 in current code.
>
> > Adding "version" constants seems good to me.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170513/a342b344/attachment.html>


More information about the Mercurial-devel mailing list