Issue1168

classification
Title: ast module not working
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: certik, fwierzbicki
Priority: Keywords:

Created on 2008-11-09.01:57:29 by certik, last changed 2009-03-02.20:38:33 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
ast_test.py certik, 2008-11-09.01:57:28
Messages
msg3765 (view) Author: Ondrej Certik (certik) Date: 2008-11-09.01:57:28
Attached find a pure python
script (with no external dependecies) that reproduces the problem.

python2.6:

$ python2.6 ast_test.py
<__main__.Integer object at 0xb7bcf96c>
<__main__.Div object at 0xb7bcfbac>
<__main__.Mul object at 0xb7bcfbec>


jython

$ jython ast_test.py
Traceback (most recent call last):
 File "ast_test.py", line 79, in <module>
   print parse_expr("1", {})
 File "ast_test.py", line 75, in parse_expr
   a = Transform(local_dict, global_dict).visit(a)
 File "/home/ondra/repos/jython/dist/Lib/ast.py", line 256, in visit
   return visitor(node)
 File "/home/ondra/repos/jython/dist/Lib/ast.py", line 321, in generic_visit
   new_node = self.visit(old_value)
 File "/home/ondra/repos/jython/dist/Lib/ast.py", line 256, in visit
   return visitor(node)
 File "ast_test.py", line 36, in visit_Num
   return fix_missing_locations(Call(Name('Integer', Load()),
TypeError: org.python.antlr.ast.Name(): expected 3-4 args; got 2
msg3770 (view) Author: Ondrej Certik (certik) Date: 2008-11-10.07:13:56
This now works. Thanks for the fix!

Now try to add this line at the end of the script:

print parse_expr("Integer(3)", {})

and run it:

$ python2.6 ast_test.py 
<__main__.Integer object at 0xb7ba092c>
<__main__.Div object at 0xb7ba0b6c>
<__main__.Mul object at 0xb7ba0bac>
<__main__.Integer object at 0xb7ba0a6c>
$ jython ast_test.py 
<__main__.Integer object at 1>
<__main__.Div object at 2>
<__main__.Mul object at 3>
Traceback (most recent call last):
  File "ast_test.py", line 82, in <module>
    print parse_expr("Integer(3)", {})
  File "ast_test.py", line 75, in parse_expr
    a = Transform(local_dict, global_dict).visit(a)
  File "/home/ondra/repos/jython/dist/Lib/ast.py", line 256, in visit
    return visitor(node)
  File "/home/ondra/repos/jython/dist/Lib/ast.py", line 321, in
generic_visit
    new_node = self.visit(old_value)
  File "/home/ondra/repos/jython/dist/Lib/ast.py", line 256, in visit
    return visitor(node)
  File "/home/ondra/repos/jython/dist/Lib/ast.py", line 319, in
generic_visit
    old_value[:] = new_values
TypeError: can only assign array (not "list") to array slice


And there will probably be couple more. I'll try to isolate it.
msg4167 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-03-02.20:38:33
The specific issues here are fixed now, so I'm closing this one.
History
Date User Action Args
2009-03-02 20:38:33fwierzbickisetstatus: open -> closed
resolution: fixed
messages: + msg4167
2008-12-14 17:16:00fwierzbickisetcomponents: + Core
2008-11-10 21:43:45fwierzbickisetassignee: fwierzbicki
nosy: + fwierzbicki
2008-11-10 07:13:57certiksetmessages: + msg3770
2008-11-09 01:57:29certikcreate