Skip to content

Give module code a source span - #2129

Open
BCSharp wants to merge 1 commit into
IronLanguages:mainfrom
BCSharp:module-span
Open

BCSharp wants to merge 1 commit into
IronLanguages:mainfrom
BCSharp:module-span

Conversation

@BCSharp

@BCSharp BCSharp commented Nov 1, 2026

Copy link
Copy Markdown
Member

PythonAst never got a location, so the code object of module, exec and eval code spanned line 1 only: co_firstlineno was always 1, and setting f_lineno from a trace function failed for any line but 1.

This PR sets the span of PythonAst when parsing finishes, from its first statement to the end of its body, which gives co_firstlineno the same as in CPython 3.4.
It also places the entry sequence point at that start, so the 'call' trace event agrees with co_firstlineno.

I noticed also that IronPython does not handle well modules with the same name, which is quite likely when exec-ing a string (often given a name "<string>"). This is not addressed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant