question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

stack_data, executing, and pure_eval

See original GitHub issue

Hi! I’ve recently created a few libraries that are helpful for extracting information from frames and tracebacks, and I think they could be very useful to sentry.

  • executing can identify the exact AST node being executed by a frame in many cases. It’s always disappointed me that Python only points to a line in each frame in tracebacks, especially when the expression/statement at fault spans many lines. Sometimes it can be really hard to interpret. Currently executing is used in IPython (in master, unreleased) to highlight the node, here’s what it looks like:

ipython

  • executing can also infer a function __qualname__ from a code object, meaning your traceback can say lorem/ipsum.py in MyClass.__init__ at line 123 instead of just __init__, which is much more informative.
  • pure_eval can safely evaluate certain AST nodes without side effects, so that if the source for a frame contains expressions like self.foo and bar[key] their values can often be shown alongside plain variables.
  • stack_data collects data from tracebacks for the purpose of formatting and displaying them. It uses executing and pure_eval and also provides a lot of functionality of its own. For example, in this frame:

Screen Shot 2020-06-27 at 19 57 57

there are lines from complex_filter which the user doesn’t need to see, and stack_data knows how to filter those out by only collecting lines which belong in the current scope. I integratedstack_data into IPython which allowed removing a lot of flaky custom introspection code, fixing several bugs and making the code more maintainable.

  • stack_data identifies the locations of variables and evaluated expressions in the source lines. An intelligent UI could use this, for example, to allow the user to hover over a variable in source code to see its value rather than scroll through a list to find it.

Overall there are lots of possibilities. What would interest you? I’m willing to make a PR and make any necessary changes to the libraries.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
alexmojakicommented, Jul 15, 2020

Yes.

0reactions
github-actions[bot]commented, Dec 23, 2021

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone … forever!


“A weed is but an unloved flower.” ― Ella Wheeler Wilcox 🥀

Read more comments on GitHub >

github_iconTop Results From Across the Web

python-stack-data 0.6.1-1 (any) - Arch Linux
Architecture: any. Repository: Community. Description: Extract data from python stack frames and tracebacks for informative displays.
Read more >
python-stack-data (aarch64) | Packages - Arch Linux ARM
Architecture: any. Repository: community. Description: Extract data from python stack frames and tracebacks for informative displays.
Read more >
ipythonMAJ.MIN entry points are not installed #13815 - GitHub
... executing>=1.2.0 Downloading executing-1.2.0-py2.py3-none-any.whl (24 ... pure-eval-0.2.2 pygments-2.13.0 six-1.16.0 stack-data-0.6.0 ...
Read more >
Ubuntu – Details of package python3-stack-data in jammy
dep: python3-executing: Inspect Python AST node being executed. dep: python3-pure-eval: Safely evaluate Python AST nodes without side effects ...
Read more >
2036909 – Review Request: python-stack-data - Extract data from ...
Spec URL: https://lbalhar.fedorapeople.org/python-stack-data.spec SRPM URL: ... python3.10dist(executing) python3.10dist(pure-eval) Provides ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found