Verificando a compatibilidade na compilação de tipos de extensão e usando-os com o cdef

Perguntas permanentes:Por que outros erros na compilação do Cython apontam para a linha de erro específica, enquanto isso não acontece?Antes da atualização:

Devido à dificuldade em compilar os tipos de extensão, conforme mencionado no link 'não será compilado' abaixo, pensou-se que o AssertionError estivesse relacionado aos tipos de extensão (depois que a instanciação foi transferida para o arquivo pyx principal).

Alguém dissopostagem no fórum disse que "se você realmente deseja tipos de extensão e deseja declarar seus tipos em seu código, precisa declarar os atributos C em um arquivo .pxd".

Se isso for verdade neste caso, o problema é que os arquivos pyxnão compilará para mim ao usar arquivos pxd. Não há erro ao compilar o tipo de extensão em um arquivo pyx, mas recebo o erroextTypeName is not a type identifier quando o tipo de extensão é usado após a importação.

Foi-me dito nocomentários esses tipos de extensão podem ser definidos no arquivo pyx com a função principal. Ao fazer isso, recebo um erro que não sei como rastrear (AssertionError: unexpected type int and base type tuple object for indexing) O traceback completo está publicado abaixo.

Difícil rastrear erro

Traceback ao tentar compilar com os tipos de extensão declarados no mesmo arquivo pyx (que não sei se é a origem do problema):

Traceback (most recent call last):
  File "setup.py", line 37, in <module>
    ext_modules = [Extension("HintToCRdict", ["HintToCRdict.pyx"])]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Library/Python/2.7/site-packages/Cython/Distutils/build_ext.py", line 164, in run
    _build_ext.build_ext.run(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 337, in run
    self.build_extensions()
  File "/Library/Python/2.7/site-packages/Cython/Distutils/build_ext.py", line 171, in build_extensions
    ext.sources = self.cython_sources(ext.sources, ext)
  File "/Library/Python/2.7/site-packages/Cython/Distutils/build_ext.py", line 324, in cython_sources
    full_module_name=module_name)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Main.py", line 688, in compile
    return compile_single(source, options, full_module_name)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Main.py", line 638, in compile_single
    return run_pipeline(source, options, full_module_name)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Main.py", line 495, in run_pipeline
    err, enddata = Pipeline.run_pipeline(pipeline, source)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Pipeline.py", line 365, in run_pipeline
    data = phase(data)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Pipeline.py", line 53, in generate_pyx_code_stage
    module_node.process_implementation(options, result)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/ModuleNode.py", line 131, in process_implementation
    self.generate_c_code(env, options, result)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/ModuleNode.py", line 359, in generate_c_code
    self.body.generate_function_definitions(env, code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 435, in generate_function_definitions
    stat.generate_function_definitions(env, code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 1944, in generate_function_definitions
    self.generate_function_body(env, code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 1698, in generate_function_body
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 5851, in generate_execution_code
    if_clause.generate_execution_code(code, end_label, is_last=i == last)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 5894, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/UtilNodes.py", line 321, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 6402, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/UtilNodes.py", line 321, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 6402, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 5851, in generate_execution_code
    if_clause.generate_execution_code(code, end_label, is_last=i == last)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 5894, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/UtilNodes.py", line 89, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 6015, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 6192, in generate_execution_code
    self.body.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 441, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 4786, in generate_execution_code
    self.generate_rhs_evaluation_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/Nodes.py", line 5073, in generate_rhs_evaluation_code
    self.rhs.generate_evaluation_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/ExprNodes.py", line 699, in generate_evaluation_code
    self.generate_subexpr_evaluation_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/ExprNodes.py", line 714, in generate_subexpr_evaluation_code
    node.generate_evaluation_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/ExprNodes.py", line 699, in generate_evaluation_code
    self.generate_subexpr_evaluation_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/ExprNodes.py", line 714, in generate_subexpr_evaluation_code
    node.generate_evaluation_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/ExprNodes.py", line 705, in generate_evaluation_code
    self.generate_result_code(code)
  File "/Library/Python/2.7/site-packages/Cython/Compiler/ExprNodes.py", line 3737, in generate_result_code
    self.type, self.base.type)
AssertionError: unexpected type int and base type tuple object for indexing

questionAnswers(2)

yourAnswerToTheQuestion