summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unparse.py
diff options
context:
space:
mode:
authorHakan Çelik <hakancelik96@outlook.com>2020-04-16 10:11:55 (GMT)
committerGitHub <noreply@github.com>2020-04-16 10:11:55 (GMT)
commit6a5bf15c71a1c101c28774ae714b58e8a65b130c (patch)
tree855baa83bf6ea2ef737d886f6b1d984a6a90ca8e /Lib/test/test_unparse.py
parent01508dcde47af993288134ab85d09ad03b43113c (diff)
downloadcpython-6a5bf15c71a1c101c28774ae714b58e8a65b130c.zip
cpython-6a5bf15c71a1c101c28774ae714b58e8a65b130c.tar.gz
cpython-6a5bf15c71a1c101c28774ae714b58e8a65b130c.tar.bz2
bpo-40209: Use tokenize.open in test_unparse (GH-19399)
Diffstat (limited to 'Lib/test/test_unparse.py')
-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 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 = """\