@@ -99,6 +99,8 @@ def _sizeof_void_p():
99
99
100
100
ENCODING = locale .getpreferredencoding ()
101
101
102
+ FRAME_INFO_OPTIMIZED_OUT = '(frame information optimized out)'
103
+ UNABLE_READ_INFO_PYTHON_FRAME = 'Unable to read information on python frame'
102
104
EVALFRAME = '_PyEval_EvalFrameDefault'
103
105
104
106
class NullPyObjectPtr (RuntimeError ):
@@ -918,7 +920,7 @@ def get_var_by_name(self, name):
918
920
def filename (self ):
919
921
'''Get the path of the current Python source file, as a string'''
920
922
if self .is_optimized_out ():
921
- return '(frame information optimized out)'
923
+ return FRAME_INFO_OPTIMIZED_OUT
922
924
return self .co_filename .proxyval (set ())
923
925
924
926
def current_line_num (self ):
@@ -949,7 +951,7 @@ def current_line(self):
949
951
'''Get the text of the current source line as a string, with a trailing
950
952
newline character'''
951
953
if self .is_optimized_out ():
952
- return '(frame information optimized out)'
954
+ return FRAME_INFO_OPTIMIZED_OUT
953
955
954
956
lineno = self .current_line_num ()
955
957
if lineno is None :
@@ -970,7 +972,7 @@ def current_line(self):
970
972
971
973
def write_repr (self , out , visited ):
972
974
if self .is_optimized_out ():
973
- out .write ('(frame information optimized out)' )
975
+ out .write (FRAME_INFO_OPTIMIZED_OUT )
974
976
return
975
977
lineno = self .current_line_num ()
976
978
lineno = str (lineno ) if lineno is not None else "?"
@@ -993,7 +995,7 @@ def write_repr(self, out, visited):
993
995
994
996
def print_traceback (self ):
995
997
if self .is_optimized_out ():
996
- sys .stdout .write (' (frame information optimized out) \n ' )
998
+ sys .stdout .write (' %s \n ' % FRAME_INFO_OPTIMIZED_OUT )
997
999
return
998
1000
visited = set ()
999
1001
lineno = self .current_line_num ()
@@ -1744,7 +1746,7 @@ def invoke(self, args, from_tty):
1744
1746
1745
1747
pyop = frame .get_pyop ()
1746
1748
if not pyop or pyop .is_optimized_out ():
1747
- print ('Unable to read information on python frame' )
1749
+ print (UNABLE_READ_INFO_PYTHON_FRAME )
1748
1750
return
1749
1751
1750
1752
filename = pyop .filename ()
@@ -1904,7 +1906,7 @@ def invoke(self, args, from_tty):
1904
1906
1905
1907
pyop_frame = frame .get_pyop ()
1906
1908
if not pyop_frame :
1907
- print ('Unable to read information on python frame' )
1909
+ print (UNABLE_READ_INFO_PYTHON_FRAME )
1908
1910
return
1909
1911
1910
1912
pyop_var , scope = pyop_frame .get_var_by_name (name )
@@ -1938,7 +1940,7 @@ def invoke(self, args, from_tty):
1938
1940
1939
1941
pyop_frame = frame .get_pyop ()
1940
1942
if not pyop_frame :
1941
- print ('Unable to read information on python frame' )
1943
+ print (UNABLE_READ_INFO_PYTHON_FRAME )
1942
1944
return
1943
1945
1944
1946
for pyop_name , pyop_value in pyop_frame .iter_locals ():
0 commit comments