Skip to content

Fix for #791 #792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Immediately close file object
  • Loading branch information
sebastinas committed Jan 29, 2020
commit 777c0a67f70b9aeff55cfc70add2d56dfd577f10
13 changes: 9 additions & 4 deletions bpython/importcompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

SUFFIXES = importlib.machinery.all_suffixes()
else:
import imp

SUFFIXES = [suffix for suffix, mode, type in imp.get_suffixes()]

# The cached list of all known modules
Expand Down Expand Up @@ -158,20 +160,23 @@ def find_modules(path):
# Workaround for issue #166
continue
try:
is_package = False
with warnings.catch_warnings():
warnings.simplefilter("ignore", ImportWarning)
fo, pathname, _ = imp.find_module(name, [path])
if fo is not None:
fo.close()
else:
# Yay, package
is_package = True
except (ImportError, IOError, SyntaxError):
continue
except UnicodeEncodeError:
# Happens with Python 3 when there is a filename in some
# invalid encoding
continue
else:
if fo is not None:
fo.close()
else:
# Yay, package
if is_package:
for subname in find_modules(pathname):
if subname != "__init__":
yield "%s.%s" % (name, subname)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy