@@ -660,14 +660,14 @@ def test_implicit_binary_modes(self):
660660 def test_text_modes (self ):
661661 uncompressed = data1 .decode ("ascii" ) * 50
662662 uncompressed_raw = uncompressed .replace ("\n " , os .linesep )
663- with gzip .open (self .filename , "wt" ) as f :
663+ with gzip .open (self .filename , "wt" , encoding = "ascii" ) as f :
664664 f .write (uncompressed )
665665 with open (self .filename , "rb" ) as f :
666666 file_data = gzip .decompress (f .read ()).decode ("ascii" )
667667 self .assertEqual (file_data , uncompressed_raw )
668- with gzip .open (self .filename , "rt" ) as f :
668+ with gzip .open (self .filename , "rt" , encoding = "ascii" ) as f :
669669 self .assertEqual (f .read (), uncompressed )
670- with gzip .open (self .filename , "at" ) as f :
670+ with gzip .open (self .filename , "at" , encoding = "ascii" ) as f :
671671 f .write (uncompressed )
672672 with open (self .filename , "rb" ) as f :
673673 file_data = gzip .decompress (f .read ()).decode ("ascii" )
@@ -681,7 +681,7 @@ def test_fileobj(self):
681681 self .assertEqual (f .read (), uncompressed_bytes )
682682 with gzip .open (io .BytesIO (compressed ), "rb" ) as f :
683683 self .assertEqual (f .read (), uncompressed_bytes )
684- with gzip .open (io .BytesIO (compressed ), "rt" ) as f :
684+ with gzip .open (io .BytesIO (compressed ), "rt" , encoding = "ascii" ) as f :
685685 self .assertEqual (f .read (), uncompressed_str )
686686
687687 def test_bad_params (self ):
@@ -722,9 +722,9 @@ def test_encoding_error_handler(self):
722722 def test_newline (self ):
723723 # Test with explicit newline (universal newline mode disabled).
724724 uncompressed = data1 .decode ("ascii" ) * 50
725- with gzip .open (self .filename , "wt" , newline = "\n " ) as f :
725+ with gzip .open (self .filename , "wt" , encoding = "ascii" , newline = "\n " ) as f :
726726 f .write (uncompressed )
727- with gzip .open (self .filename , "rt" , newline = "\r " ) as f :
727+ with gzip .open (self .filename , "rt" , encoding = "ascii" , newline = "\r " ) as f :
728728 self .assertEqual (f .readlines (), [uncompressed ])
729729
730730
0 commit comments