PyDict_SetItemString segfaults

后端 未结 1 789
名媛妹妹
名媛妹妹 2021-01-21 15:19

I am trying to write a simple C extension for Python3, and it segfaults when I try to add a string to a dictionary. Here is my code:

#include 
#in         


        
相关标签:
1条回答
  • 2021-01-21 15:46

    You forgot to initialize the interpreter:

    Py_Initialize();
    

    A program that embeds Python must initialize the interpreter before attempting to call any Python functions. This is not necessary for extension modules, which are loaded by an already-initialized interpreter.

    0 讨论(0)
提交回复
热议问题