Skip to content

Commit 2c3cbd7

Browse files
committed
Specify loaders for FileFinder (fixes #847)
Otherwise the FileFinder.find_spec does not know how to handle the file extensions.
1 parent 6438d27 commit 2c3cbd7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bpython/importcompletion.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The MIT License
22
#
33
# Copyright (c) 2009-2011 Andreas Stuehrk
4-
# Copyright (c) 2020 Sebastian Ramacher
4+
# Copyright (c) 2020-2021 Sebastian Ramacher
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal
@@ -35,6 +35,16 @@
3535
)
3636

3737
SUFFIXES = importlib.machinery.all_suffixes()
38+
LOADERS = (
39+
(
40+
importlib.machinery.ExtensionFileLoader,
41+
importlib.machinery.EXTENSION_SUFFIXES,
42+
),
43+
(
44+
importlib.machinery.SourceFileLoader,
45+
importlib.machinery.SOURCE_SUFFIXES
46+
),
47+
)
3848

3949

4050
class ModuleGatherer:
@@ -144,7 +154,7 @@ def find_modules(self, path):
144154
# Path is not readable
145155
return
146156

147-
finder = importlib.machinery.FileFinder(str(path))
157+
finder = importlib.machinery.FileFinder(str(path), *LOADERS)
148158
for p in children:
149159
if any(fnmatch.fnmatch(p.name, entry) for entry in self.skiplist):
150160
# Path is on skiplist

0 commit comments

Comments
 (0)