From: Hakan Çelik Date: Thu, 16 Apr 2020 10:11:55 +0000 (+0300) Subject: bpo-40209: Use tokenize.open in test_unparse (GH-19399) X-Git-Tag: v3.9.0a6~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a5bf15c71a1c101c28774ae714b58e8a65b130c;p=thirdparty%2FPython%2Fcpython.git bpo-40209: Use tokenize.open in test_unparse (GH-19399) --- diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index 23292640086b..d4089a3fc1cd 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -11,11 +11,8 @@ import ast def read_pyfile(filename): """Read and return the contents of a Python source file (as a string), taking into account the file encoding.""" - with open(filename, "rb") as pyfile: - encoding = tokenize.detect_encoding(pyfile.readline)[0] - with open(filename, "r", encoding=encoding) as pyfile: - source = pyfile.read() - return source + with tokenize.open(filename) as stream: + return stream.read() for_else = """\