-
Notifications
You must be signed in to change notification settings - Fork 49
Improve tracebacks #691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve tracebacks #691
Conversation
* Use "logical" function names in traceback rather than the "real" function name. (For example, in a nested function, use the function name instead of __call__.) * Omit glue and helper functions from tracebacks. (This is implemented by skipping tracebacks for functions that don't have a "logical" name.) Closes #428, #614.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is a big usability improvement. I left few style comments.
mypyc/ops.py
Outdated
self.decl = decl | ||
self.blocks = blocks | ||
self.env = env | ||
self.traceback_name = traceback_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it may be a bit premature, but I would start adding doc comments for attributes (mostly for motivation).
mypyc/exceptions.py
Outdated
@@ -86,7 +86,7 @@ def split_blocks_at_errors(blocks: List[BasicBlock], | |||
op=variant, | |||
line=op.line) | |||
branch.negated = negated | |||
if op.line != NO_TRACEBACK_LINE_NO: | |||
if op.line != NO_TRACEBACK_LINE_NO and func: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May this cause troubles is a mypy bug will generate function with .fullname
set to None
(or an empty string)?
Also TBH I would rename this argument to func_name
and write ... and func_name is not None
.
globals_static = emitter.static_name('globals', module_name) | ||
traceback_code = 'CPy_AddTraceback("%s", "%s", %d, %s);' % ( | ||
source_path.replace("\\", "\\\\"), | ||
fn.traceback_name or fn.name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move this logic to .name
(which is a property)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather be explicit about it here. But I'll add a comment explaining why we are doing a traceback at all when there is no traceback_name, even though we don't in other cases.
* Use "logical" function names in traceback rather than the "real" function name. (For example, in a nested function, use the function name instead of __call__.) * Omit glue and helper functions from tracebacks. (This is implemented by skipping tracebacks for functions that don't have a "logical" name.) Closes mypyc/mypyc#428, mypyc/mypyc#614.
function name. (For example, in a nested function, use the function
name instead of
__call__.
)implemented by skipping tracebacks for functions that don't have a
"logical" name.)
Closes #428
Closes #614