Show More
@@ -7,6 +7,7 b' Much of the code is taken from the tokenize module in Python 3.2.' | |||||
7 |
|
7 | |||
8 | import io |
|
8 | import io | |
9 | from io import TextIOWrapper, BytesIO |
|
9 | from io import TextIOWrapper, BytesIO | |
|
10 | from pathlib import Path | |||
10 | import re |
|
11 | import re | |
11 | from tokenize import open, detect_encoding |
|
12 | from tokenize import open, detect_encoding | |
12 |
|
13 | |||
@@ -72,7 +73,8 b' def read_py_file(filename, skip_encoding_cookie=True):' | |||||
72 | ------- |
|
73 | ------- | |
73 | A unicode string containing the contents of the file. |
|
74 | A unicode string containing the contents of the file. | |
74 | """ |
|
75 | """ | |
75 | with open(filename) as f: # the open function defined in this module. |
|
76 | filepath = Path(filename) | |
|
77 | with open(filepath) as f: # the open function defined in this module. | |||
76 | if skip_encoding_cookie: |
|
78 | if skip_encoding_cookie: | |
77 | return "".join(strip_encoding_cookie(f)) |
|
79 | return "".join(strip_encoding_cookie(f)) | |
78 | else: |
|
80 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now