Skip to content

Commit 0c465a0

Browse files
Add encoding detecting to modulefinder
1 parent e02ab59 commit 0c465a0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Lib/modulefinder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import types
1010
import warnings
11+
import tokenize
1112

1213

1314
LOAD_CONST = dis.opmap['LOAD_CONST']
@@ -93,7 +94,11 @@ def _find_module(name, path=None):
9394
else: # Should never happen.
9495
return None, None, ("", "", _SEARCH_ERROR)
9596

96-
file = open(file_path, mode)
97+
if mode == 'r':
98+
file = open(file_path)
99+
else:
100+
file = open(file_path, mode)
101+
97102
suffix = os.path.splitext(file_path)[-1]
98103

99104
return file, file_path, (suffix, mode, kind)

0 commit comments

Comments
 (0)