@@ -165,8 +165,8 @@ def using_bytecode_benchmark(seconds, repeat):
165165
166166def main (import_ , options ):
167167 if options .source_file :
168- with options .source_file :
169- prev_results = json .load (options . source_file )
168+ with open ( options .source_file , 'r' , encoding = 'utf-8' ) as source_file :
169+ prev_results = json .load (source_file )
170170 else :
171171 prev_results = {}
172172 __builtins__ .__import__ = import_
@@ -218,8 +218,8 @@ def main(import_, options):
218218 new_result / old_result )
219219 print (benchmark_name , ':' , result )
220220 if options .dest_file :
221- with options .dest_file :
222- json .dump (new_results , options . dest_file , indent = 2 )
221+ with open ( options .dest_file , 'w' , encoding = 'utf-8' ) as dest_file :
222+ json .dump (new_results , dest_file , indent = 2 )
223223
224224
225225if __name__ == '__main__' :
@@ -229,11 +229,9 @@ def main(import_, options):
229229 parser .add_argument ('-b' , '--builtin' , dest = 'builtin' , action = 'store_true' ,
230230 default = False , help = "use the built-in __import__" )
231231 parser .add_argument ('-r' , '--read' , dest = 'source_file' ,
232- type = argparse .FileType ('r' ),
233232 help = 'file to read benchmark data from to compare '
234233 'against' )
235234 parser .add_argument ('-w' , '--write' , dest = 'dest_file' ,
236- type = argparse .FileType ('w' ),
237235 help = 'file to write benchmark data to' )
238236 parser .add_argument ('--benchmark' , dest = 'benchmark' ,
239237 help = 'specific benchmark to run' )
0 commit comments