mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +00:00
bpo-40209: Use tokenize.open in test_unparse (GH-19399)
This commit is contained in:
parent
01508dcde4
commit
6a5bf15c71
1 changed files with 2 additions and 5 deletions
|
@ -11,11 +11,8 @@ import ast
|
||||||
def read_pyfile(filename):
|
def read_pyfile(filename):
|
||||||
"""Read and return the contents of a Python source file (as a
|
"""Read and return the contents of a Python source file (as a
|
||||||
string), taking into account the file encoding."""
|
string), taking into account the file encoding."""
|
||||||
with open(filename, "rb") as pyfile:
|
with tokenize.open(filename) as stream:
|
||||||
encoding = tokenize.detect_encoding(pyfile.readline)[0]
|
return stream.read()
|
||||||
with open(filename, "r", encoding=encoding) as pyfile:
|
|
||||||
source = pyfile.read()
|
|
||||||
return source
|
|
||||||
|
|
||||||
|
|
||||||
for_else = """\
|
for_else = """\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue