File tree Expand file tree Collapse file tree 1 file changed +1
-17
lines changed
Expand file tree Collapse file tree 1 file changed +1
-17
lines changed Original file line number Diff line number Diff line change @@ -131,25 +131,9 @@ def find_locale_dir():
131131#: Block size used when reading files for hashing:
132132HASH_BLOCK_SIZE = 512 * 1024
133133
134-
135- def open_text_file (filename , mode = "r" , encoding = "utf-8" , errors = "strict" ):
136- # Open the underlying file in binary mode so the codec wrapper keeps codecs.open() behavior without its deprecation.
137- binary_mode = mode .replace ("t" , "" )
138- if "b" not in binary_mode :
139- binary_mode += "b"
140-
141- stream = open (filename , binary_mode )
142- if "r" in mode and all (flag not in mode for flag in ("w" , "a" , "+" )):
143- wrapped = codecs .getreader (encoding )(stream , errors = errors )
144- else :
145- wrapped = codecs .getwriter (encoding )(stream , errors = errors )
146-
147- wrapped .encoding = codecs .lookup (encoding ).name .upper ()
148- return wrapped
149-
150-
151134#: Convenience function used everywhere we want to open a file to read text
152135#: rather than undecoded bytes:
136+ open_text_file = partial (open , encoding = "utf-8" , errors = "strict" )
153137
154138# This is the same as decoding the byte values in codecs.BOM:
155139UNICODE_BYTE_ORDER_MARK = "\ufeff "
You can’t perform that action at this time.
0 commit comments