[issue4724] setting f_exc_traceback aborts in debug builds

Alexander Belopolsky report at bugs.python.org
Wed Feb 2 20:46:04 CET 2011


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

Not applicable to 3.x because the frame object does not have f_exc_traceback attribute anymore:

>>> import sys;sys._getframe(0).f_exc_traceback = 23
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'frame' object has no attribute 'f_exc_traceback'

The issue is present in 2.7 but appears to be rather benign.   It looks like the worst that can happen in non-debug build is a reference leak in set_exc_info().

I am not sure if this is worth fixing.  If this was affecting development version, I would argue that the simplest fix is to disallow setting f_exc_traceback or f_exc_value before f_exc_type is set.  In a bug-fix reliase, however this is probably not acceptable.

Given that sys._getframe() screams "beware, expert use only", I am not sure anything should be done other than possibly documenting that assigning to f_exc_* attributes of a transient frame object is not a good idea.

Note that the following works:

>>> f = sys._getframe(0)
>>> f.f_exc_traceback = 23

If there is a legitimate use for setting f_exc_traceback, the user should know to set f.f_exc_type and f.f_exc_value as well.

----------
nosy: +belopolsky -BreamoreBoy
versions:  -Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4724>
_______________________________________


More information about the Python-bugs-list mailing list