aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_unparse.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py
index 23292640086..d4089a3fc1c 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 = """\