[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-25 Thread Irit Katriel
Irit Katriel added the comment: Try the search function on the tracker (that's what I would need to do to find what to link). -- ___ Python tracker ___

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-25 Thread Martin
Martin added the comment: Thanks for your definitive answer, this is what I was waiting for. I understand and I totally agree that subclassing is the way to go to make traceback more flexible. Would you mind linking the other issues concerning the general improvement of traceback?

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-25 Thread Irit Katriel
Irit Katriel added the comment: While I do think this module should be more customisable than it is, I think it should be done via support for subclassing rather than injecting functions that get forwarded on as you do here. There are other issues on bpo related to customising this module,

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-25 Thread Martin
Martin added the comment: Irit, would you be able to take a look at the patch? --- I found another application scenario for the patch: In Numpy and Pandas, the assert_* functions in testing have a __tracebackhide__ local that advises pytest to hide the frame. With the patch in place, we

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-10 Thread Martin
Martin added the comment: Thanks Joe! > 1. The changes are sufficient to let the user make things work the way it is > requested that they work and anyone who does not start using the new > format_locals parameter will get the old behavior. That was my goal :) > 2. A side comment: I just

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-09 Thread Joe Wells
Joe Wells added the comment: Some quick comments on Martin's pull request. 1. The changes are sufficient to let the user make things work the way it is requested that they work and anyone who does not start using the new format_locals parameter will get the old behavior. 2. A side comment:

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-09 Thread Ken Jin
Change by Ken Jin : -- nosy: -kj ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-09 Thread Martin
Martin added the comment: I improved the example in traceback.rst to illustrate how format_locals works. -- ___ Python tracker ___

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-09 Thread Martin
Martin added the comment: Just to avoid misunderstandings: My pull request is not at all about silencing exceptions. It is about customizing the output of the traceback module. (Just like the introduction of capture_locals previously: #22936) (-X capture_locals, on the other hand, is a

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-08 Thread Andrei Kulakov
Andrei Kulakov added the comment: Martin: I have a couple of concerns: - Generally (AFAIK) Python is very conservative about silencing arbitrary exceptions. There are a few functions with args like `ignore_errors`, but those are for errors in the logic of respective functions. I don't

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-08 Thread Martin
Martin added the comment: I see two scenarious discussed here: Scenario 1 (Offline / Batch-Mode): A system runs user-supplied jobs that may fail. In the case of an error, the system shouldn't crash but rather store a maximally helpful message and carry on with the next job. Most likely, the

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-07 Thread Andrei Kulakov
Andrei Kulakov added the comment: Martin: I'm not sure what is the best way to fix this issue, so I hope someone else will look into this. -- ___ Python tracker ___

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-11-07 Thread Martin
Martin added the comment: Could the participants of this issue please have a look at my pull request: https://github.com/python/cpython/pull/29299 What do you like, what don't you like? Does it work for your use case? -- ___ Python tracker

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-28 Thread Martin
Change by Martin : -- pull_requests: +27563 stage: resolved -> patch review pull_request: https://github.com/python/cpython/pull/29299 ___ Python tracker ___

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-28 Thread Martin
Martin added the comment: Once again a very good summary, thanks Joe! > it would be quite useful if this function parameter was given not just the > local variable values, but also the name of the local variable and maybe also > the stack frame it is in So this would be something like

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-28 Thread Joe Wells
Joe Wells added the comment: 1. As background, it is worth remembering that a major motivation for why FrameSummary.__init__ stringifies the local variable values in its parameter locals is to prevent the resulting data structure from keeping those values live. This enables them to be

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-26 Thread Andrei Kulakov
Andrei Kulakov added the comment: Martin: It's true that exceptions raised in other methods called from __init__ would still have this issue, but I feel like ~90% of it would be solved by the proposed fix. It does introduce an inconsistency but it does so because it reflects the

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-26 Thread Irit Katriel
Irit Katriel added the comment: Martin, how about something like: "This is typically used for debugging, so it is important that the representation is information-rich and unambiguous. Furthermore, this function should not raise exceptions because that can make it inappropriate for use in

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-26 Thread Martin
Martin added the comment: Irit, I'm unsure about the wording. Something like ":meth:`__repr__` should always succeed, even if errors prevent a full description of the object."? "... even if the object is only partly initialized."? Andrei, I think you can not simply omit the first argument.

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-25 Thread Irit Katriel
Irit Katriel added the comment: Martin, would you like to submit a patch with this addition to the doc? -- ___ Python tracker ___

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-25 Thread Andrei Kulakov
Andrei Kulakov added the comment: I've been thinking that perhaps it makes sense to special case printing of `self` argument in `__init__` methods. The same exact issue happens with PDB `args` command in `__init__` methods. My idea is that in the __init__, you generally don't want to print

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-25 Thread Martin
Martin added the comment: > Can we determine if they came from an initialized object or from object in > the middle of initialization? That would be very nice because inside __init__ is the only place where we have to deal with partly initialized objects. But I think Python does not provide

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-22 Thread Irit Katriel
Irit Katriel added the comment: See also 23597. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-21 Thread Andrei Kulakov
Andrei Kulakov added the comment: Martin: I was also thinking of adding a parameter to `extract()`. The issue I see is that it's still confusing and complicated for new students to understand the issue and find the parameter and understand why it's needed. Joe: one important thing to note

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-20 Thread Martin
Martin added the comment: Thanks, Joe, this is a very good summary of all the problems. Another idea to fix this could be an additional parameter "repr=repr" to StackSummary.extract. This way, the default behavior is not changed, but the user is allowed to supply their own repr (safe_repr

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-20 Thread Joe Wells
Joe Wells added the comment: In the hopes of convincing someone to install a fix to this bug, I will mention a few additional points. When I mention “the capture_locals feature”, I mean calls of the form traceback.TracebackException(..., capture_locals=True) and

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-20 Thread Andrei Kulakov
Andrei Kulakov added the comment: Joe: I understand your point but my concern is that this creates an impression for the users that Python is tolerant of failing __repr__'s, while that's not the case at all. I agree that if StackSummary was only used for interactive debugging, there would

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-20 Thread Joe Wells
Joe Wells added the comment: Andrei, thanks very much for the pointer to bug/issue https://bugs.python.org/issue39228. I had not noticed the earlier comment by Irit pointing to that bug. (Is there some way to merge bugs so that someone visiting one of the bugs will see the merged stream

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-20 Thread Joe Wells
Joe Wells added the comment: I'm sorry Andrei: I misread your alteration of my example and misunderstood its purpose. For anyone else reading these messages: In my most recent comment above, please ignore the part of my comment about Andrei's example. So yes, Andrei, that is how people

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-20 Thread Andrei Kulakov
Andrei Kulakov added the comment: Joe: I've looked at https://bugs.python.org/issue39228 again and I see there was consensus to reject this idea, please take a look at the discussion there. -- ___ Python tracker

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-20 Thread Andrei Kulakov
Andrei Kulakov added the comment: Joe: when I ran your code sample with modification I posted previously, I don't get any errors. Can you try running it? By the way my point was not that builtin __repr__ should be modified to never raise exceptions (which would not help in this case), but

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-20 Thread Joe Wells
Joe Wells added the comment: Here are my thoughts inspired by Andrei's insightful comments. 1. In response to the major issue Andrei raises, I agree that it is desirable that repr would never raise an exception. The reasons Andrei mentions seem quite correct to me. However, I think the

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-19 Thread Andrei Kulakov
Andrei Kulakov added the comment: Joe: I would argue that it should be expected that every object instantiated from a class should have a safe __repr__, because you will have logging and if a __repr__ is broken in some rare circumstances, it may bring down your production system in the

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-19 Thread Andrei Kulakov
Andrei Kulakov added the comment: related issue: https://bugs.python.org/issue20853 similarly to this, if args cmd is used in pdb in the TestClass __init__ method, `self` will be displayed, which means the TestClass.__str__ or __repr__ will run, lacking any required state set in the

[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-19 Thread Joe Wells
Joe Wells added the comment: I would like to request that this bug be repopened and fixed. I've changed (or at least tried to change, I'm not sure if it will let me) the title of the bug to point out that the failure happens in FrameSummary.__init__. It does not happen in