3939
4040csv .field_size_limit (10485760 ) # The default value is 128KB; upping to 10MB. See SPL-12117 for background on this issue
4141
42- if sys .platform == 'win32' :
42+ # SPL-175233 -- python3 stdout is already binary
43+ if sys .platform == 'win32' and sys .version_info <= (3 , 0 ):
4344 # Work around the fact that on Windows '\n' is mapped to '\r\n'. The typical solution is to simply open files in
4445 # binary mode, but stdout is already open, thus this hack. 'CPython' and 'PyPy' work differently. We assume that
4546 # all other Python implementations are compatible with 'CPython'. This might or might not be a valid assumption.
@@ -339,6 +340,8 @@ class CsvDialect(csv.Dialect):
339340 doublequote = True
340341 skipinitialspace = False
341342 lineterminator = '\r \n '
343+ if sys .version_info >= (3 , 0 ) and sys .platform == 'win32' :
344+ lineterminator = '\n '
342345 quoting = csv .QUOTE_MINIMAL
343346
344347
@@ -658,6 +661,13 @@ class RecordWriterV1(RecordWriter):
658661
659662 def flush (self , finished = None , partial = None ):
660663
664+ # SPL-175233
665+ def writeEOL ():
666+ if sys .version_info >= (3 , 0 ) and sys .platform == 'win32' :
667+ write ('\n ' )
668+ else :
669+ write ('\r \n ' )
670+
661671 RecordWriter .flush (self , finished , partial ) # validates arguments and the state of this instance
662672
663673 if self ._record_count > 0 or (self ._chunk_count == 0 and 'messages' in self ._inspector ):
@@ -678,9 +688,9 @@ def flush(self, finished=None, partial=None):
678688 write (message_level (level , level ))
679689 write ('=' )
680690 write (text )
681- write ( ' \r \n ' )
691+ writeEOL ( )
682692
683- write ( ' \r \n ' )
693+ writeEOL ( )
684694
685695 elif messages is not None :
686696
0 commit comments