I have no idea. I know very little about python and the ocaml-python interface. Perhaps there is a library that is not included. But it is strange that you test one thing in your script code and another thing when you run python directly. Why not test the same code in both cases?

I would suggest to just modify the code and make it work as you want, ie insert a conversion from int to string if that is what is needed. I don't think there is anyone working on coccinelle that has the time or expertise to solve this kind of problem.

On the other hand, if you find the solution yourself, ie a library open that is missing, that could be added to the implementation.

julia

On Wed, 28 Dec 2011, SF Markus Elfring wrote:

Perhaps your append function is not able to take an integer as an argument?

If I try out the following statements, ...

@script:python collection depends on !is_void@
typ << function_declaration.t;
fun << function_declaration.f;
places << function_declaration.p;
@@
for place in places:
   fields = []
   fields.append(12345)


... I get also another unexpected reaction.

elfring@Sonne:~/Projekte/Coccinelle/lokal/demos/return_values> spatch -sp_file select_non_void_functions.cocci example1b.c
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: example1b.c
Traceback (most recent call last):
 File "<string>", line 10, in <module>
TypeError: sequence item 0: expected string, int found
Failure in collection
Fatal error: exception Pycocci.Pycocciexception


Why does Coccinelle's scripting interface not support an integer at this place when this parameter passing works as expected in a standard execution environment?

elfring@Sonne:~> python
Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on linux2
...
fields = []
fields.append("ABC")
fields.append(12345)
print(fields)
['ABC', 12345]

elfring@Sonne:~> python3
Python 3.2.1 (default, Jul 18 2011, 16:24:40) [GCC] on linux2
...
fields = []
fields.append("ABC")
fields.append(12345)
print(fields)
['ABC', 12345]



Regards,
Markus

_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to