This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyObject *PyInit_myextention -> PyMODINIT_FUNC PyInit_myextention
Type: Stage: resolved
Components: Documentation Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: brett.cannon, docs@python, prinsherbert, python-dev
Priority: normal Keywords: easy

Created on 2016-04-22 12:08 by prinsherbert, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (6)
msg264005 - (view) Author: Herbert (prinsherbert) Date: 2016-04-22 12:08
I think 

PyObject *PyInit_myextention(void)

should be

PyMODINIT_FUNC PyInit_myextention(void)

on https://docs.python.org/3/howto/cporting.html#module-initialization-and-state

It didn't work for me until I replaced this with a message in the about 'undefined PyInit_myextention'. However, when I used nm to inspect the .so object file, I fond the PyInit_myextention (but probably with the wrong return type). Moreover, whenever I would remove the same .so importing resulted in a different error complaining that the module does not exist (strongly suggesting that I did not mix up .so files).

Good luck!
msg264006 - (view) Author: Herbert (prinsherbert) Date: 2016-04-22 12:09
The exact error was:

ImportError: dynamic module does not define init function (PyInit_myextension)
msg264024 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-04-22 15:48
https://docs.python.org/3/extending/extending.html#the-module-s-method-table-and-initialization-function documents what Herbert discovered wrong in the porting docs.
msg264025 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-04-22 15:49
And in case my comment wasn't obvious, Herbert is right about the error in the docs.
msg264049 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-23 06:43
New changeset 188af2b4945a by Benjamin Peterson in branch '3.5':
fix python 3 mod init function declaration (closes #26827)
https://hg.python.org/cpython/rev/188af2b4945a

New changeset df0e900b8860 by Benjamin Peterson in branch 'default':
merge 3.5 (#26827)
https://hg.python.org/cpython/rev/df0e900b8860
msg264050 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-23 06:49
New changeset 8d6bd32a56a8 by Benjamin Peterson in branch '2.7':
fix python 3 mod init function declaration (closes #26827)
https://hg.python.org/cpython/rev/8d6bd32a56a8
History
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71014
2016-04-23 06:49:21python-devsetmessages: + msg264050
2016-04-23 06:43:32python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg264049

resolution: fixed
stage: resolved
2016-04-22 15:49:11brett.cannonsetmessages: + msg264025
2016-04-22 15:48:34brett.cannonsetkeywords: + easy
nosy: + brett.cannon
messages: + msg264024

2016-04-22 12:09:57prinsherbertsetmessages: + msg264006
2016-04-22 12:08:15prinsherbertcreate