From 6a5bf15c71a1c101c28774ae714b58e8a65b130c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20=C3=87elik?= Date: Thu, 16 Apr 2020 13:11:55 +0300 Subject: bpo-40209: Use tokenize.open in test_unparse (GH-19399) --- Lib/test/test_unparse.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index 2329264..d4089a3 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 = """\ -- cgit v0.12