Search code examples
pythonpython-3.xnative-code

Py_InitModule and PyString_InternFromString in Python 3.5


I want to update my Python version from 2.7 to 3.5.

When compiling code that uses PyString_InternFromString and this Py_InitModule

I get error messages:

Error   199 error C3861: 'Py_InitModule': identifier not found
Error   196 error C3861: 'PyString_InternFromString': identifier not found

My question is, What is the equivalent to those identifiers in python 3.5?


Solution

  • For Py_InitModule, you're now using PyModule_Create. You can see example usage in the tutorial example on the Python docs page.

    For interning, Py3's str is based on the Py2 unicode type; at the C-layer, you're using PyUnicode methods, e.g. PyUnicode_InternFromString. You're still interning Python level strs, but the implementation type has changed.