We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 01508dc commit 6a5bf15Copy full SHA for 6a5bf15
Lib/test/test_unparse.py
@@ -11,11 +11,8 @@
11
def read_pyfile(filename):
12
"""Read and return the contents of a Python source file (as a
13
string), taking into account the file encoding."""
14
- with open(filename, "rb") as pyfile:
15
- encoding = tokenize.detect_encoding(pyfile.readline)[0]
16
- with open(filename, "r", encoding=encoding) as pyfile:
17
- source = pyfile.read()
18
- return source
+ with tokenize.open(filename) as stream:
+ return stream.read()
19
20
21
for_else = """\
0 commit comments