@@ -99,6 +99,8 @@ def _sizeof_void_p():
9999
100100ENCODING = locale .getpreferredencoding ()
101101
102+ FRAME_INFO_OPTIMIZED_OUT = '(frame information optimized out)'
103+ UNABLE_READ_INFO_PYTHON_FRAME = 'Unable to read information on python frame'
102104EVALFRAME = '_PyEval_EvalFrameDefault'
103105
104106class NullPyObjectPtr (RuntimeError ):
@@ -918,7 +920,7 @@ def get_var_by_name(self, name):
918920 def filename (self ):
919921 '''Get the path of the current Python source file, as a string'''
920922 if self .is_optimized_out ():
921- return '(frame information optimized out)'
923+ return FRAME_INFO_OPTIMIZED_OUT
922924 return self .co_filename .proxyval (set ())
923925
924926 def current_line_num (self ):
@@ -949,7 +951,7 @@ def current_line(self):
949951 '''Get the text of the current source line as a string, with a trailing
950952 newline character'''
951953 if self .is_optimized_out ():
952- return '(frame information optimized out)'
954+ return FRAME_INFO_OPTIMIZED_OUT
953955
954956 lineno = self .current_line_num ()
955957 if lineno is None :
@@ -970,7 +972,7 @@ def current_line(self):
970972
971973 def write_repr (self , out , visited ):
972974 if self .is_optimized_out ():
973- out .write ('(frame information optimized out)' )
975+ out .write (FRAME_INFO_OPTIMIZED_OUT )
974976 return
975977 lineno = self .current_line_num ()
976978 lineno = str (lineno ) if lineno is not None else "?"
@@ -993,7 +995,7 @@ def write_repr(self, out, visited):
993995
994996 def print_traceback (self ):
995997 if self .is_optimized_out ():
996- sys .stdout .write (' (frame information optimized out) \n ' )
998+ sys .stdout .write (' %s \n ' % FRAME_INFO_OPTIMIZED_OUT )
997999 return
9981000 visited = set ()
9991001 lineno = self .current_line_num ()
@@ -1744,7 +1746,7 @@ def invoke(self, args, from_tty):
17441746
17451747 pyop = frame .get_pyop ()
17461748 if not pyop or pyop .is_optimized_out ():
1747- print ('Unable to read information on python frame' )
1749+ print (UNABLE_READ_INFO_PYTHON_FRAME )
17481750 return
17491751
17501752 filename = pyop .filename ()
@@ -1904,7 +1906,7 @@ def invoke(self, args, from_tty):
19041906
19051907 pyop_frame = frame .get_pyop ()
19061908 if not pyop_frame :
1907- print ('Unable to read information on python frame' )
1909+ print (UNABLE_READ_INFO_PYTHON_FRAME )
19081910 return
19091911
19101912 pyop_var , scope = pyop_frame .get_var_by_name (name )
@@ -1938,7 +1940,7 @@ def invoke(self, args, from_tty):
19381940
19391941 pyop_frame = frame .get_pyop ()
19401942 if not pyop_frame :
1941- print ('Unable to read information on python frame' )
1943+ print (UNABLE_READ_INFO_PYTHON_FRAME )
19421944 return
19431945
19441946 for pyop_name , pyop_value in pyop_frame .iter_locals ():
0 commit comments