Expand self
See original GitHub issueA common problem with object oriented code is that the crash logs in sentry don’t contain the relevant variables because they live on self. So instead of “a = 2, b = 3” you’d get “self = <SomeClass at 0xdeadmeat>”. This makes it much more difficult to reproduce and fix the bug. We could instead expand members of self that have been used! Proof of concept looks something like this:
from __future__ import print_function
import inspect
import re
class Foo(object):
def __init__(self):
self.a = 1
self.b = 2
self.c = 3
self.d = 6
def foo(self):
x = self.c + self.d
raise Exception()
def format_stack(frame):
frame_info = inspect.getframeinfo(frame)
print('---- %s:%s ----' % (frame_info.filename, frame_info.lineno))
for k, v in frame.tb_frame.f_locals.items():
print('%s: %s' % (k, v))
if k == 'self':
source = inspect.getsource(frame)
for self_member in re.findall(r'self\.(\w)', source):
print('self.%s: %s' % (self_member, getattr(v, self_member)))
if frame.tb_next:
format_stack(frame)
try:
Foo().foo()
except Exception as e:
import sys
tb = sys.exc_info()[2]
format_stack(tb.tb_next)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Self-expansion model - Wikipedia
Self -expansion theory was proposed by Arthur Aron. It is a model used to explain how people maintain the close relationships in their...
Read more >Self-Expansion Theory in Social Psychology - iResearchNet
The motivation to self-expand is tied to people's ability to accomplish their goals, thus self-expansion is related to psychological models of self-efficacy, ...
Read more >Manipulation of Self-Expansion Alters Responses to Attractive ...
Aron and Aron's (1986) self-expansion model of close relationships posits that people are motivated to enter relationships in order to enhance ...
Read more >12 Ways to Expand Yourself | personal growth ideas ...
Personal growth ideas to expand yourself in 2019, add these to your goals or new years resolution's list! Make sure to check all...
Read more >Self-Expansion in Romantic Relationships | Psychology Today
When we self-expand, we're essentially widening our understanding of who we are, what we're able to do, and how we view life. For...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is still very important.
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
orStatus: In Progress
, I will leave it alone … forever!“A weed is but an unloved flower.” ― Ella Wheeler Wilcox 🥀