@@ -1130,8 +1130,10 @@ def open(self, mode="r", buffering=-1, encoding=None, errors=None, newline=None)
11301130 Open the file pointed by this path and return a file object, as
11311131 the built-in open() function does.
11321132 """
1133- if "b" not in mode :
1134- encoding = io .text_encoding (encoding )
1133+ # bitranox - io.text_encoding exists only on 3.10 upwards
1134+ if sys .version_info <= (3 , 10 ):
1135+ if "b" not in mode :
1136+ encoding = io .text_encoding (encoding )
11351137 return io .open (self , mode , buffering , encoding , errors , newline )
11361138
11371139 def read_bytes (self ):
@@ -1145,7 +1147,9 @@ def read_text(self, encoding=None, errors=None):
11451147 """
11461148 Open the file in text mode, read it, and close the file.
11471149 """
1148- encoding = io .text_encoding (encoding )
1150+ # bitranox - io.text_encoding exists only on 3.10 upwards
1151+ if sys .version_info <= (3 , 10 ):
1152+ encoding = io .text_encoding (encoding )
11491153 with self .open (mode = "r" , encoding = encoding , errors = errors ) as f :
11501154 return f .read ()
11511155
@@ -1164,7 +1168,11 @@ def write_text(self, data, encoding=None, errors=None, newline=None):
11641168 """
11651169 if not isinstance (data , str ):
11661170 raise TypeError ("data must be str, not %s" % data .__class__ .__name__ )
1167- encoding = io .text_encoding (encoding )
1171+
1172+ # bitranox - io.text_encoding exists only on 3.10 upwards
1173+ if sys .version_info <= (3 , 10 ):
1174+ encoding = io .text_encoding (encoding )
1175+
11681176 with self .open (mode = "w" , encoding = encoding , errors = errors , newline = newline ) as f :
11691177 return f .write (data )
11701178
0 commit comments