Author christian.heimes
Recipients christian.heimes, corona10, larry, vstinner
Date 2020-11-19.11:40:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Sometimes the converter function for CConverter must access the current module object in order to access the current module state. Currently CConverter subclasses have no easy way to pass the module to the converter function. It would be fantastic if easier CConverter would get an option to pass the module.


GH-23398 converts the struct module to multiphase initialization. The struct module has a converter for cached struct definitions. The cache used to be a module level object. It is now an interpreter scoped object. I used a custom parse_arg() function to pass the module object:

class cache_struct_converter(CConverter):
    type = 'PyStructObject *'
    converter = 'cache_struct_converter'
    c_default = "NULL"

    def parse_arg(self, argname, displayname):
        return """
            if (!{converter}(module, {argname}, &{paramname})) {{{{
                goto exit;

    def cleanup(self):
        return "Py_XDECREF(%s);\n" %
Date User Action Args
2020-11-19 11:40:44christian.heimessetrecipients: + christian.heimes, vstinner, larry, corona10
2020-11-19 11:40:44christian.heimessetmessageid: <>
2020-11-19 11:40:44christian.heimeslinkissue42404 messages
2020-11-19 11:40:44christian.heimescreate