Skip to content

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

Merged
merged 2 commits into from
Aug 20, 2019
Merged

Improve tracebacks #691

merged 2 commits into from
Aug 20, 2019

Conversation

msullivan
Copy link
Collaborator

@msullivan msullivan commented Aug 19, 2019

  • 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
Closes #614

 * 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.
@msullivan msullivan requested review from JukkaL and ilevkivskyi and removed request for JukkaL August 20, 2019 00:11
Copy link
Collaborator

@ilevkivskyi ilevkivskyi left a 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
Copy link
Collaborator

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).

@@ -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:
Copy link
Collaborator

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,
Copy link
Collaborator

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)?

Copy link
Collaborator Author

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.

@msullivan msullivan merged commit cffbb79 into master Aug 20, 2019
@msullivan msullivan deleted the traceback-improvements branch August 20, 2019 21:18
msullivan added a commit to python/mypy that referenced this pull request Aug 20, 2019
 * 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.
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.

Tracebacks contain noise due to glue methods Emit better function names in traceback
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy