[Pyrex] CFuncTypeArg instance has no attribute 'assignable_from'

Radek Smejkal radek.smejkal at laicatc.com
Mon Jun 19 18:43:46 CEST 2017


Hi,

The shrubbery example from "Using Pyrex with C++" fails to compile
with Pyrex 0.9.9.

Traceback (most recent call last):
   File "pyrexc.py", line 6, in <module>
     main(command_line = 1)
   File "Pyrex/Compiler/Main.py", line 526, in main
     result = compile(sources, options)
   File "Pyrex/Compiler/Main.py", line 506, in compile
     return compile_multiple(source, options)
   File "Pyrex/Compiler/Main.py", line 477, in compile_multiple
     result = context.compile(source, options)
   File "Pyrex/Compiler/Main.py", line 333, in compile
     tree.process_implementation(imp_scope, options, result)
   File "Pyrex/Compiler/ModuleNode.py", line 43, in process_implementation
     self.body.analyse_expressions(env)
   File "Pyrex/Compiler/Nodes.py", line 118, in analyse_expressions
     stat.analyse_expressions(env)
   File "Pyrex/Compiler/Nodes.py", line 1474, in analyse_expressions
     self.analyse_types(env)
   File "Pyrex/Compiler/Nodes.py", line 1495, in analyse_types
     self.rhs.analyse_types(env)
   File "Pyrex/Compiler/ExprNodes.py", line 1651, in analyse_types
     func_type = self.resolve_overloading()
   File "Pyrex/Compiler/ExprNodes.py", line 1670, in resolve_overloading
     if signature.callable_with(arg_types):
   File "Pyrex/Compiler/PyrexTypes.py", line 571, in callable_with
     if not formal_type.assignable_from(actual_type):
AttributeError: CFuncTypeArg instance has no attribute 'assignable_from'


shrubbery.pyx+
cdef extern from "somewhere.h":

     cdef+ struct Shrubbery:
         __init__()
         __init__(float width)
         __init__(float width, int price)
         float width
         int height
         void plant_with_rhododendrons(int howmany)

cdef Shrubbery *sh1, *sh2, *sh3
sh1 = new Shrubbery()
sh2 = new Shrubbery(3.2)
sh3 = new Shrubbery(4.3, 800)


Patch for Pyrex 0.9.9
--- Pyrex/Compiler/PyrexTypes.py.orig	2010-04-09 11:21:36.000000000 +0200
+++ Pyrex/Compiler/PyrexTypes.py	2014-09-06 00:08:10.000000000 +0200
@@ -562,7 +562,7 @@
              string.join(arg_reprs, ","))

      def callable_with(self, actual_arg_types):
-        formal_arg_types = self.args
+        formal_arg_types = [arg.type for arg in self.args]
          nf = len(formal_arg_types)
          na = len(actual_arg_types)
          if not (nf == na or self.has_varargs and nf >= na):


Radek



More information about the Pyrex mailing list