2

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?

200_success
  • 7,286
  • 1
  • 43
  • 74
Ramy
  • 172
  • 1
  • 17
  • for `py_InitModule` [python 3 uses a different structure](http://stackoverflow.com/questions/28305731/compiler-cant-find-py-initmodule-is-it-deprecated-and-if-so-what-should-i) and for `PyString_InternFromString`, it is just [unavailable for python 3](https://docs.python.org/2/c-api/string.html#c.PyString_InternFromString) – R Nar Nov 11 '15 at 00:00
  • @RNar: [Interning is still there, it's just that the C level type of the Python `str` changed.](https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_InternFromString) – ShadowRanger Nov 11 '15 at 00:12

2 Answers2

1

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.

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
0

https://stackoverflow.com/a/28306354/320546 will help you with Py_InitModule and PyStr_InternFromString is the Python 3 equivalent of PyString_InternFromString (see http://py3c.readthedocs.org/en/latest/reference.html#c.PyStr_InternFromString)

Community
  • 1
  • 1
Tom Parker-Shemilt
  • 1,679
  • 15
  • 26
  • `PyStr_InternFromString` is from a third party compatibility library, it's not the "Python 3 equivalent" of anything, it's a wrapper that calls the Py2 or Py3 version of the function, as appropriate. – ShadowRanger Nov 11 '15 at 00:13