Skip to content

Commit 5a5c309

Browse files
author
Łukasz Langa
committed
Fix for spurious ImportWarnings when python is invoked with -Wd
1 parent 13c4d2d commit 5a5c309

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bpython/importcompletion.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import imp
2525
import os
2626
import sys
27+
import warnings
2728

2829
py3 = sys.version_info[:2] >= (3, 0)
2930

@@ -105,7 +106,9 @@ def find_modules(path):
105106
continue
106107
name = os.path.splitext(name)[0]
107108
try:
108-
fo, pathname, _ = imp.find_module(name, [path])
109+
with warnings.catch_warnings():
110+
warnings.simplefilter("ignore", ImportWarning)
111+
fo, pathname, _ = imp.find_module(name, [path])
109112
except (ImportError, SyntaxError):
110113
continue
111114
except UnicodeEncodeError:

0 commit comments

Comments
 (0)