Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sebastinas merged 2 commits intomasterfromissue-791
Jan 29, 2020
Merged
Changes fromall commits
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
30 changes: 24 additions & 6 deletionsbpython/importcompletion.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,6 @@
current_from_import_import,
)

import imp
import os
import sys
import warnings
Expand All@@ -43,6 +42,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 DownExpand Up@@ -141,6 +142,10 @@ def find_modules(path):
filenames = os.listdir(path)
except EnvironmentError:
filenames = []

if py3:
finder = importlib.machinery.FileFinder(path)

for name in filenames:
if not any(name.endswith(suffix) for suffix in SUFFIXES):
# Possibly a package
Expand All@@ -158,20 +163,33 @@ 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 py3:
spec = finder.find_spec(name)
if spec is None:
continue
if spec.submodule_search_locations is not None:
pathname = spec.submodule_search_locations[0]
is_package = True
else:
pathname = spec.origin
else:
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

[8]ページ先頭

©2009-2026 Movatter.jp