[docs] Small error in the "Extending Python with C" page

Sandro Tosi sandro.tosi at gmail.com
Tue Aug 14 20:58:27 CEST 2012


Hello Hadrien,
given I have no experience nor knowledge to judge the correctness of
your proposed fix, I've just reported
http://bugs.python.org/issue15656 .

Regards,
Sandro

On Sat, Jul 7, 2012 at 2:35 PM, Hadrien Titeux <hadwarez at gmail.com> wrote:
> Hello,
>
> I've recenty started to try using C code in python using the wonderful
> python API, although i have to say the learning curve was non neglectable :P
> I've spotted what I believe to be a small mistake in the documentation from
> this page:
> http://docs.python.org/release/3.2/extending/extending.html
>
> In paragraph 1.8
> (http://docs.python.org/release/3.2/extending/extending.html#keyword-parameters-for-extension-functions),
> the code example given contains an error, which is actually obsolete code
> from python 2.7:
>
> void
> initkeywdarg(void)
> {
>   /* Create the module and add the functions */
>   Py_InitModule("keywdarg", keywdarg_methods);
> }
>
>
> This doesn't work in Python3.2. It's supposed to be
>
> static struct PyModuleDef keywdargmodule = {
>    PyModuleDef_HEAD_INIT,
>    "keywdarg",   /* name of module */
>    keywdarg_doc, /* module documentation, may be NULL */
>    -1,       /* size of per-interpreter state of the module,
>                 or -1 if the module keeps state in global variables. */
>    keywdarg_methods
> };
>
> PyMODINIT_FUNC
> PyInit_keywdarg(void)
> {
>     return PyModule_Create(&keywdargmodule);
> }
>
> As explained above (and confirmed by experience).
>
> Thanks for your work,
> Hadrien.
>
> _______________________________________________
> docs mailing list
> docs at python.org
> http://mail.python.org/mailman/listinfo/docs
>

-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi


More information about the docs mailing list