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.

Author michael.foord
Recipients BreamoreBoy, dmalcolm, michael.foord, purcell, rbcollins, rhettinger
Date 2010-12-08.16:21:47
SpamBayes Score 1.3602862e-08
Marked as misclassified No
Message-id <1291825317.86.0.948990989339.issue1705520@psf.upfronthosting.co.za>
In-reply-to
Content
So from the stackframe you can only get to the code object not to the function object and although the code object is also reachable from a decorator it isn't mutable so we can't "mark it" in any way. We could in theory 're-build' the function and create a new code object (__code__ is assignable) by copying the original but adding a non-existent name to one of the code attributes. This is pretty horrible though.

So a *real* local variable (as suggested by Robert) would work, but the functionality wouldn't work on IronPython and would cause tools like pyflakes to complain about an unused name.

Another alternative is to use the docstring. This is available via code_object.co_consts[0], so we could use a marker in the docstring to indicate that this frame should be omitted from tracebacks. Unless we can make the marker either invisible (magic whitespace anyone?) or non-invasive this is also a not so pleasant idea. (And wouldn't work with -OO.)

Alternative suggestions welcomed.
History
Date User Action Args
2010-12-08 16:21:58michael.foordsetrecipients: + michael.foord, rhettinger, purcell, rbcollins, dmalcolm, BreamoreBoy
2010-12-08 16:21:57michael.foordsetmessageid: <1291825317.86.0.948990989339.issue1705520@psf.upfronthosting.co.za>
2010-12-08 16:21:47michael.foordlinkissue1705520 messages
2010-12-08 16:21:47michael.foordcreate