@@ -459,7 +459,7 @@ def write_chunk(chunk, i):
459
459
cl_sep = 'wakaUnknownBefore(); var asm=wakaUnknownAfter(global,env,buffer)\n '
460
460
461
461
cle = temp_files .get ('.cl.js' ).name
462
- c = open (cle , 'w ' )
462
+ c = open (cle , 'wb ' )
463
463
pre_1 , pre_2 = pre .split (start_asm )
464
464
post_1 , post_2 = post .split (end_asm )
465
465
c .write (pre_1 )
@@ -470,7 +470,7 @@ def write_chunk(chunk, i):
470
470
if split_memory :
471
471
if DEBUG : print >> sys .stderr , 'running splitMemory on shell code'
472
472
cld = run_on_chunk (js_engine + [JS_OPTIMIZER , cld , 'splitMemoryShell' ])
473
- f = open (cld , 'a ' )
473
+ f = open (cld , 'ab ' )
474
474
f .write (suffix_marker )
475
475
f .close ()
476
476
if closure :
@@ -481,9 +481,9 @@ def write_chunk(chunk, i):
481
481
if DEBUG : print >> sys .stderr , 'running cleanup on shell code'
482
482
next = cld + '.cl.js'
483
483
temp_files .note (next )
484
- subprocess .Popen (js_engine + [JS_OPTIMIZER , cld , 'noPrintMetadata' ] + (['minifyWhitespace' ] if 'minifyWhitespace' in passes else []), stdout = open (next , 'w ' )).communicate ()
484
+ subprocess .Popen (js_engine + [JS_OPTIMIZER , cld , 'noPrintMetadata' ] + (['minifyWhitespace' ] if 'minifyWhitespace' in passes else []), stdout = open (next , 'wb ' )).communicate ()
485
485
cld = next
486
- coutput = open (cld ).read ()
486
+ coutput = open (cld , 'rb' ).read ()
487
487
coutput = coutput .replace ('wakaUnknownBefore();' , start_asm )
488
488
after = 'wakaUnknownAfter'
489
489
start = coutput .find (after )
@@ -492,15 +492,15 @@ def write_chunk(chunk, i):
492
492
post = post_1 + end_asm + coutput [end + 1 :]
493
493
494
494
filename += '.jo.js'
495
- f = open (filename , 'w ' )
495
+ f = open (filename , 'wb ' )
496
496
f .write (pre );
497
497
pre = None
498
498
499
499
if not just_concat :
500
500
# sort functions by size, to make diffing easier and to improve aot times
501
501
funcses = []
502
502
for out_file in filenames :
503
- funcses .append (split_funcs (open (out_file ).read (), False ))
503
+ funcses .append (split_funcs (open (out_file , 'rb' ).read (), False ))
504
504
funcs = [item for sublist in funcses for item in sublist ]
505
505
funcses = None
506
506
def sorter (x , y ):
@@ -523,11 +523,11 @@ def sorter(x, y):
523
523
else :
524
524
# just concat the outputs
525
525
for out_file in filenames :
526
- f .write (open (out_file ).read ())
527
- f .write (' \n ' )
526
+ f .write (open (out_file , 'rb' ).read ())
527
+ f .write (os . linesep ) # Writing in binary mode, so make sure to generate correct newline output
528
528
f .write (post );
529
529
# No need to write suffix: if there was one, it is inside post which exists when suffix is there
530
- f .write (' \n ' )
530
+ f .write (os . linesep )
531
531
f .close ()
532
532
533
533
return filename
0 commit comments