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.

A 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:open
  • Created 5 years ago
  • Reactions:4
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
boxedcommented, Dec 23, 2021

This is still very important.

1reaction
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

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 >

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