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