[issue19585] Frame annotation

2014-01-15 Thread Nick Coghlan
Nick Coghlan added the comment: Another use case from frame annotations: allowing greenlets and threads to indicate which greenlet or thread a traceback is from whenever it is printed (this is similar to the way the runtime indicates which thread a traceback occurred in when it terminates the

[issue19585] Frame annotation

2013-11-25 Thread Nick Coghlan
Nick Coghlan added the comment: A nested function will always share the code object between its instances - the nested code object is a compile time constant stored as part of the containing code object. Any code object attribute must be consistent for the lifetime of the object. -- __

[issue19585] Frame annotation

2013-11-25 Thread Walter Dörwald
Walter Dörwald added the comment: Do you have an example where code objects are shared? We could attach the annotation formatter to the function object, but unfortunately the function object is now accessible in the traceback. Note the co_annotation is not the annotation string, rather it is a

[issue19585] Frame annotation

2013-11-25 Thread Nick Coghlan
Nick Coghlan added the comment: Code objects are shared amongst multiple function objects, so you can't store mutable state on them. -- ___ Python tracker ___ ___

[issue19585] Frame annotation

2013-11-25 Thread Walter Dörwald
Walter Dörwald added the comment: Here is a new version of the patch. The annotation is done on the code object instead of on the frame object. This avoids two problems: There is no runtime overhead, as the decorator returns the original function and no additional frames show up in the traceba

[issue19585] Frame annotation

2013-11-14 Thread Nick Coghlan
Nick Coghlan added the comment: Aye, it would. The improved exception chaining and frame hiding ideas in issue 18861 are also related. The part I particularly like in Walter's suggestion is the idea of a "frame description" that is displayed in the traceback for that frame, without the traceback

[issue19585] Frame annotation

2013-11-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: I think this would need a PEP. -- nosy: +ncoghlan, pitrou ___ Python tracker ___ ___ Python-bugs-lis

[issue19585] Frame annotation

2013-11-14 Thread Walter Dörwald
Walter Dörwald added the comment: See http://bugs.python.org/issue18861 and the discussion started here: https://mail.python.org/pipermail/python-dev/2013-November/130155.html. Basically it allows to add context information to a traceback without changing the type of the exception. In the fol

[issue19585] Frame annotation

2013-11-14 Thread STINNER Victor
STINNER Victor added the comment: What is the use case of frame annotations? -- nosy: +haypo ___ Python tracker ___ ___ Python-bugs-li

[issue19585] Frame annotation

2013-11-14 Thread Walter Dörwald
New submission from Walter Dörwald: This patch adds frame annotations, i.e. it adds an attribute f_annotation to frame objects, a decorator to set this attribute on exceptions and extensions to the traceback machinery that display the annotation in the traceback. -- components: Interpr