@@ -188,22 +188,25 @@ def visit_function_obj(v, ids_seen_set):
188188
189189class PGLogger (bdb .Bdb ):
190190
191- def __init__ (self , cumulative_mode , finalizer_func , disable_security_checks = False ):
191+ def __init__ (self , cumulative_mode , heap_primitives , finalizer_func , disable_security_checks = False ):
192192 bdb .Bdb .__init__ (self )
193193 self .mainpyfile = ''
194194 self ._wait_for_mainpyfile = 0
195195
196196 self .disable_security_checks = disable_security_checks
197197
198- # a function that takes the output trace as a parameter and
199- # processes it
200- self .finalizer_func = finalizer_func
201-
202198 # if True, then displays ALL stack frames that have ever existed
203199 # rather than only those currently on the stack (and their
204200 # lexical parents)
205201 self .cumulative_mode = cumulative_mode
206202
203+ # if True, then render certain primitive objects as heap objects
204+ self .render_heap_primitives = heap_primitives
205+
206+ # a function that takes the output trace as a parameter and
207+ # processes it
208+ self .finalizer_func = finalizer_func
209+
207210 # each entry contains a dict with the information for a single
208211 # executed line
209212 self .trace = []
@@ -241,7 +244,7 @@ def __init__(self, cumulative_mode, finalizer_func, disable_security_checks=Fals
241244
242245 # very important for this single object to persist throughout
243246 # execution, or else canonical small IDs won't be consistent.
244- self .encoder = pg_encoder .ObjectEncoder ()
247+ self .encoder = pg_encoder .ObjectEncoder (self . render_heap_primitives )
245248
246249 self .executed_script = None # Python script to be executed!
247250
@@ -846,8 +849,8 @@ def finalize(self):
846849
847850
848851# the MAIN meaty function!!!
849- def exec_script_str (script_str , cumulative_mode , finalizer_func ):
850- logger = PGLogger (cumulative_mode , finalizer_func )
852+ def exec_script_str (script_str , cumulative_mode , heap_primitives , finalizer_func ):
853+ logger = PGLogger (cumulative_mode , heap_primitives , finalizer_func )
851854
852855 try :
853856 logger ._runscript (script_str )
@@ -860,8 +863,8 @@ def exec_script_str(script_str, cumulative_mode, finalizer_func):
860863# disables security check and returns the result of finalizer_func
861864# WARNING: ONLY RUN THIS LOCALLY and never over the web, since
862865# security checks are disabled
863- def exec_script_str_local (script_str , cumulative_mode , finalizer_func ):
864- logger = PGLogger (cumulative_mode , finalizer_func , disable_security_checks = True )
866+ def exec_script_str_local (script_str , cumulative_mode , heap_primitives , finalizer_func ):
867+ logger = PGLogger (cumulative_mode , heap_primitives , finalizer_func , disable_security_checks = True )
865868
866869 try :
867870 logger ._runscript (script_str )
0 commit comments