main
main copied to clipboard
'frame' object has no attribute 'f_back'
Most of the attributes on Python's frame object are missing from IronPython's.
Python 2.5:
[' ** class ** ', ' ** delattr ** ', ' ** doc ** ', ' ** getattribute ** ', '
** hash ** ', ' ** init ** ', ' ** new ** ', ' ** reduce ** ', ' ** reduce_e
x ** ', ' ** repr ** ', ' ** setattr ** ', ' ** str ** ', 'f_back',
'f_builtins', 'f_code', 'f_exc_traceback', 'f_exc_type', 'f_exc_va
lue', 'f_globals', 'f_lasti', 'f_lineno', 'f_locals', 'f_restricted',
'f_trace']
IronPython 2.0A8:
[' ** class ** ', ' ** delattr ** ', ' ** doc ** ', ' ** getattribute ** ', '
** hash ** ', ' ** init ** ', ' ** new ** ', ' ** reduce ** ', ' ** reduce_e
x ** ', ' ** repr ** ', ' ** setattr ** ', ' ** str ** ', 'f_code',
'f_globals', 'f_locals']
SCons uses f_back to walk the callstack.
Work Item Details
Original CodePlex Issue: Issue 15399 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Mar 1, 2008 at 9:03 PM Reported by: jdhardy Updated on: Feb 22, 2013 at 2:15 AM Updated by: jdhardy Test: See attached and also CPy's test_sys.py (test_objecttypes) Thanks: jdhardy
Plaintext Attachments
On 2009-03-28 02:16:08 UTC, mdengler commented:
No sure if this has been fixed in 2.1, but it's still an issue in 2.0.1:
def test():
... try:
... raise Exception()
... except:
... print traceback.print_stack()
... print traceback.format_exc()
...
test()
Traceback (most recent call last):
File "
MissingMemberException : 'frame' object has no attribute 'f_back'
On 2009-05-22 03:57:38 UTC, dinov commented:
Fixed w/ -X:Frame support
On 2009-08-15 03:50:49 UTC, dfugate commented:
Implemented, but not correctly. E.g. we're getting f_lineno wrong which was the first thing I checked:
E:\vslrgrs\Merlin\Main\Languages\IronPython\Tests>type blah.py import sys import copy def foo(): some_exception_raising_code()
try: try: foo() except: excinfo1 = sys.exc_info()[2] exc1_list = [] while excinfo1: exc1_list.append((excinfo1.tb_frame.f_code.co_filename, excinfo1.tb_frame.f_code.co_name, excinfo1.tb_frame.f_lineno)) excinfo1 = excinfo1.tb_next raise except Exception, e: excinfo2 = sys.exc_info()[2] exc2_list = [] while excinfo2: exc2_list.append((excinfo2.tb_frame.f_code.co_filename, excinfo2.tb_frame.f_code.co_name, excinfo2.tb_frame.f_lineno)) excinfo2 = excinfo2.tb_next
print "DWF1:", exc1_list print "DWF2:", exc2_list
E:\vslrgrs\Merlin\Main\Languages\IronPython\Tests>26 blah.py
DWF1: [('blah.py', '
E:\vslrgrs\Merlin\Main\Languages\IronPython\Tests>ipyd -X:FullFrames blah.py DWF1: [('blah.py', 'blah.py', 1), ('blah.py', 'foo', 1)] DWF2: [('blah.py', 'blah.py', 1), ('blah.py', 'foo', 1)]
On 2009-11-24 06:30:53 UTC, donsaw commented:
If found this function from ply.lex.py does not work in latest IronPython 2.6 whereas it does work in latest Python 2.6:
import sys def get_caller_module_dict(levels): try: raise RuntimeError except RuntimeError: e,b,t = sys.exc_info() f = t.tb_frame while levels > 0: f = f.f_back levels -= 1 ldict = f.f_globals.copy() return ldict
The tb_frame has an attribute 'f_back' that is always null. Various trace functions in the "inspect" module of IronPython do not present same trace info as that module in Python. I found no solution there.
On 2010-12-13 05:42:17 UTC, rjnienaber commented:
The line number issue still seems to be occurring in 2.7b1 on .NET 4:
python blah.py
DWF1: [('blah.py', '
ipy blah.py
DWF1: [('blah.py', '