[Python-checkins] (no subject)

Hakan Çelik webhook-mailer at python.org
Thu Apr 16 06:11:59 EDT 2020




To: python-checkins at python.org
Subject: bpo-40209: Use tokenize.open in test_unparse (GH-19399)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

https://github.com/python/cpython/commit/6a5bf15c71a1c101c28774ae714b58e8a65b=
130c
commit: 6a5bf15c71a1c101c28774ae714b58e8a65b130c
branch: master
author: Hakan =C3=87elik <hakancelik96 at outlook.com>
committer: GitHub <noreply at github.com>
date: 2020-04-16T11:11:55+01:00
summary:

bpo-40209: Use tokenize.open in test_unparse (GH-19399)

files:
M Lib/test/test_unparse.py

diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py
index 23292640086b9..d4089a3fc1cdf 100644
--- a/Lib/test/test_unparse.py
+++ b/Lib/test/test_unparse.py
@@ -11,11 +11,8 @@
 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 =3D tokenize.detect_encoding(pyfile.readline)[0]
-    with open(filename, "r", encoding=3Dencoding) as pyfile:
-        source =3D pyfile.read()
-    return source
+    with tokenize.open(filename) as stream:
+        return stream.read()
=20
=20
 for_else =3D """\



More information about the Python-checkins mailing list