Michael Foord <mich...@voidspace.org.uk> added the comment:

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.

----------
nosy: +rhettinger

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1705520>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to