[Ironpython-users] IronPython, Daily Digest 11/22/2014
CodePlex
no_reply at codeplex.com
Sun Nov 23 09:22:12 CET 2014
Hi ironpython,
Here's your Daily Digest of new issues for project "IronPython".
In today's digest:ISSUES
1. [New issue] builtin’s compile function inconsistent with CPython
----------------------------------------------
ISSUES
1. [New issue] builtin’s compile function inconsistent with CPython
http://ironpython.codeplex.com/workitem/35707
User TalSaiag has proposed the issue:
"When using compile to build an AST and then using it again to compile the code, the resulting object’s source is not set.
Test function:
def test():
import ast
PyCF_ONLY_AST = 1024
PyCF_DONT_IMPLY_DEDENT = 512
source = "def f():\n return g()\ndef g():\n x = 0\n return 1 / x\nf()"
cmp = compile(source, "<asd>", "exec", PyCF_ONLY_AST | PyCF_DONT_IMPLY_DEDENT, 1)
index = 1 # g function only
node = cmp.body[index]
mod = ast.Module([node])
code = compile(mod, "<asd2>", "exec")
return code.co_filename, code.co_firstlineno
test()
In python the result should be: ('<asd2>', 3)
In IronPython it’s: ('', 1)
While trying to solve it myself, I found that the builtin’s compile (Modules\Builtin.cs:297) function doesn’t use the filename parameter given to the function in that case (while passing an AST as the source), and by passing it along to ConvertToPythonAst and in that function to the SourceUnit constructor instead of “” (Modules_ast.cs:72), the co_filename parameter is fixed.
Fixing the location is not as easy, I realized that the Node.SetLoc function is not being called upon creating a new one in Revert functions (in _ast.cs thus the Span is not set) but I’m not familiar with the code that much to find the right place (or places) to call it and with which arguments and I also think that won’t be sufficient for some reason. I’m not even sure I’m in the right track to solve this…"
----------------------------------------------
----------------------------------------------
You are receiving this email because you subscribed to notifications on CodePlex.
To report a bug, request a feature, or add a comment, visit IronPython Issue Tracker. You can unsubscribe or change your issue notification settings on CodePlex.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20141123/1f5915fb/attachment.html>
More information about the Ironpython-users
mailing list