CFuncTypeArg instance has no attribute 'assignable_from'
Radek Smejkal <[email protected]> Mon, 19 Jun 2017 18:43:46 +0200
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
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 =3D 1)
File "Pyrex/Compiler/Main.py", line 526, in main
result =3D 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 =3D 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 =3D 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 =3D new Shrubbery()
sh2 =3D new Shrubbery(3.2)
sh3 =3D 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 =3D self.args
+ formal_arg_types =3D [arg.type for arg in self.args]
nf =3D len(formal_arg_types)
na =3D len(actual_arg_types)
if not (nf =3D=3D na or self.has_varargs and nf >=3D na):
Radek