This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: traceback module has no way to show locals
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: 17911 Superseder:
Assigned To: Nosy List: BreamoreBoy, cvrebert, ezio.melotti, n, ncoghlan, python-dev, rbcollins
Priority: normal Keywords: patch

Created on 2014-11-25 02:05 by rbcollins, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue-22936-1.patch rbcollins, 2015-01-26 23:48
issue-22936-2.patch rbcollins, 2015-02-03 23:29
issue-22936-3.patch rbcollins, 2015-03-04 23:23 review
issue-22936-4.patch rbcollins, 2015-03-05 06:37 review
issue-22936-5.patch rbcollins, 2015-03-06 00:18 review
Messages (17)
msg231628 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-11-25 02:05
From https://github.com/testing-cabal/testtools/issues/111 - any code that is data dependent can be hard to diagnose from a backtrace alone. Many unittest and server environments address this by doing custom tracebacks that include locals.

To address this in unittest, we need to add a similar capacity to traceback, and then use it from unittest (as we can't just depend on a module from PyPI in the stdlib).
msg231630 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-11-25 02:07
See http://bugs.python.org/issue22936 for the unittest aspect of this.
msg231738 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-11-27 00:03
Check out the cgitb stdlib module.
msg234799 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-01-26 23:48
First cut implementation. I'm sure there is lots we can add, but this will make things nicer in and of itself.

Thanks for the pointer to cgitb, I've skimmed it and its definitely much more comprehensive. I'm not entirely sure about the best way to glue it and the new traceback API together; or even if thats needed.
msg235366 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-02-03 23:29
updated with the latest 17911 patch basis.
msg237218 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-03-04 23:14
And now updated to HEAD as 17911 has been committed.
msg237243 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2015-03-05 06:48
Latest patch (issue-22936-4.patch) looks good to me!
msg237244 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-05 07:29
New changeset 50741316dd3a by Robert Collins in branch 'default':
Issue #22936: Make it possible to show local variables in tracebacks.
https://hg.python.org/cpython/rev/50741316dd3a
msg237246 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2015-03-05 08:07
In the patch you made some args kw-only.
Isn't that backward incompatible in case someone was passing them by position?
msg237262 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2015-03-05 14:06
It's only the new APIs just introduced in issue #17911 that changed to kwonly arguments.

We missed that they should really be kwonly in the original review, but it become more obvious in this patch, as it added a second feature toggle to indicate whether or not to capture the locals.
msg237267 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2015-03-05 15:08
You are right -- I didn't notice the versionadded in the docs.
Sorry for the noise.
msg237298 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-03-05 22:39
No worries. BTW there is one more patch needed to close this issue - adding the feature to unittest. I'm working that up now.
msg237308 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-03-06 00:02
And the unittest patch.
msg237314 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-06 00:46
New changeset b4a26b28f5b3 by Robert Collins in branch 'default':
Issue #22936: Allow showing local variables in unittest errors.
https://hg.python.org/cpython/rev/b4a26b28f5b3
msg237320 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2015-03-06 02:15
I just filed issue #23597 as a potential further follow-up to this, which would be to also add support for displaying local variables directly to the logging module.

However, that has some additional security implications, so I'm entirely convinced it's a good idea yet. See the new RFE for more details.
msg237326 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-03-06 02:36
msg237320 "...so I'm *NOT* entirely convinced..."? :)
msg249169 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-08-26 00:13
This itself is fixed.
History
Date User Action Args
2022-04-11 14:58:10adminsetgithub: 67125
2015-08-26 00:13:03rbcollinssetstatus: open -> closed
resolution: fixed
messages: + msg249169

stage: resolved
2015-03-21 04:16:48r.david.murraysetnosy: + n
2015-03-21 04:16:33r.david.murraylinkissue23724 superseder
2015-03-06 02:36:33BreamoreBoysetnosy: + BreamoreBoy
messages: + msg237326
2015-03-06 02:15:06ncoghlansetdependencies: + traceback: add a new thin class storing a traceback without storing local variables
messages: + msg237320
2015-03-06 02:13:00ncoghlanlinkissue23597 dependencies
2015-03-06 00:46:55python-devsetmessages: + msg237314
2015-03-06 00:23:41gvanrossumsetnosy: - gvanrossum
2015-03-06 00:18:58rbcollinssetfiles: + issue-22936-5.patch
2015-03-06 00:18:28rbcollinssetfiles: - issue-22936-5.patch
2015-03-06 00:02:50rbcollinssetfiles: + issue-22936-5.patch

messages: + msg237308
2015-03-05 22:39:29rbcollinssetmessages: + msg237298
2015-03-05 15:08:35ezio.melottisetmessages: + msg237267
2015-03-05 14:07:00ncoghlansetmessages: + msg237262
2015-03-05 08:07:47ezio.melottisetnosy: + ezio.melotti
messages: + msg237246
2015-03-05 07:29:31python-devsetnosy: + python-dev
messages: + msg237244
2015-03-05 06:48:49ncoghlansetnosy: + ncoghlan
messages: + msg237243
2015-03-05 06:37:55rbcollinssetfiles: + issue-22936-4.patch
2015-03-04 23:23:14rbcollinssetfiles: + issue-22936-3.patch
2015-03-04 23:23:05rbcollinssetfiles: - issue-22936-3.patch
2015-03-04 23:14:22rbcollinssetfiles: + issue-22936-3.patch

messages: + msg237218
2015-02-03 23:29:22rbcollinssetfiles: + issue-22936-2.patch

messages: + msg235366
2015-01-26 23:48:17rbcollinssetfiles: + issue-22936-1.patch
keywords: + patch
messages: + msg234799
2014-11-28 18:07:22cvrebertsetnosy: + cvrebert
2014-11-27 00:03:34gvanrossumsetnosy: + gvanrossum
messages: + msg231738
2014-11-25 02:07:00rbcollinssetmessages: + msg231630
2014-11-25 02:06:34rbcollinssettype: enhancement
2014-11-25 02:05:27rbcollinscreate