@@ -40,30 +40,15 @@ def set_binary_mode(fh):
4040 """ Helper method to set up binary mode for file handles.
4141 Emphasis being sys.stdin, sys.stdout, sys.stderr.
4242 For python3, we want to return .buffer
43- For python2+windows we want to set os.O_BINARY
4443 """
45- typefile = TextIOWrapper if sys . version_info >= ( 3 , 0 ) else file
44+ typefile = TextIOWrapper
4645 # check for file handle
4746 if not isinstance (fh , typefile ):
4847 return fh
4948
50- # check for python3 and buffer
51- if sys . version_info >= ( 3 , 0 ) and hasattr (fh , 'buffer' ):
49+ # check for buffer
50+ if hasattr (fh , 'buffer' ):
5251 return fh .buffer
53- # check for python3
54- if sys .version_info >= (3 , 0 ):
55- pass
56- # check for windows python2. SPL-175233 -- python3 stdout is already binary
57- elif sys .platform == 'win32' :
58- # Work around the fact that on Windows '\n' is mapped to '\r\n'. The typical solution is to simply open files in
59- # binary mode, but stdout is already open, thus this hack. 'CPython' and 'PyPy' work differently. We assume that
60- # all other Python implementations are compatible with 'CPython'. This might or might not be a valid assumption.
61- from platform import python_implementation
62- implementation = python_implementation ()
63- if implementation == 'PyPy' :
64- return os .fdopen (fh .fileno (), 'wb' , 0 )
65- import msvcrt
66- msvcrt .setmode (fh .fileno (), os .O_BINARY )
6752 return fh
6853
6954
@@ -684,7 +669,6 @@ def _write_record(self, record):
684669 # We may be running under PyPy 2.5 which does not include the _json module
685670 _iterencode_json = JSONEncoder (separators = (',' , ':' )).iterencode
686671 else :
687- # Creating _iterencode_json this way yields a two-fold performance improvement on Python 2.7.9 and 2.7.10
688672 from json .encoder import encode_basestring_ascii
689673
690674 @staticmethod
0 commit comments