-
-
Notifications
You must be signed in to change notification settings - Fork 297
Another attempt at fixing the collections.abc
issue for Python 3.13
#2665
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
Changes from all commits
5306ff5
c3240c0
4665d93
0c768c8
f5fe7d3
768768e
18ccd48
e9ff949
11cf784
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,15 +143,45 @@ | |
type=ModuleType.C_BUILTIN, | ||
) | ||
|
||
if submodule_path is not None: | ||
search_paths = list(submodule_path) | ||
else: | ||
search_paths = sys.path | ||
|
||
suffixes = (".py", ".pyi", importlib.machinery.BYTECODE_SUFFIXES[0]) | ||
for entry in search_paths: | ||
package_directory = os.path.join(entry, modname) | ||
for suffix in suffixes: | ||
package_file_name = "__init__" + suffix | ||
file_path = os.path.join(package_directory, package_file_name) | ||
if cached_os_path_isfile(file_path): | ||
return ModuleSpec( | ||
name=modname, | ||
location=package_directory, | ||
type=ModuleType.PKG_DIRECTORY, | ||
) | ||
for suffix, type_ in ImportlibFinder._SUFFIXES: | ||
file_name = modname + suffix | ||
file_path = os.path.join(entry, file_name) | ||
if cached_os_path_isfile(file_path): | ||
return ModuleSpec(name=modname, location=file_path, type=type_) | ||
|
||
# sys.stdlib_module_names was added in Python 3.10 | ||
if PY310_PLUS: | ||
# If the module is a stdlib module, check whether this is a frozen module. Note that | ||
# `find_spec` actually imports the module, so we want to make sure we only run this code | ||
# for stuff that can be expected to be frozen. For now this is only stdlib. | ||
# If the module name matches a stdlib module name, check whether this is a frozen | ||
# module. Note that `find_spec` actually imports parent modules, so we want to make | ||
# sure we only run this code for stuff that can be expected to be frozen. For now | ||
# this is only stdlib. | ||
if modname in sys.stdlib_module_names or ( | ||
processed and processed[0] in sys.stdlib_module_names | ||
): | ||
jacobtylerwalls marked this conversation as resolved.
Show resolved
Hide resolved
|
||
spec = importlib.util.find_spec(".".join((*processed, modname))) | ||
try: | ||
with warnings.catch_warnings(): | ||
warnings.filterwarnings("ignore", category=Warning) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about limiting this to UserWarning for parity with #2121? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran into issues with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright. It seems like a little bit of a regression that we're importing stdlib modules in more cases now, but I guess we have no choice really. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah.. I really don't know of any other way to fix this. |
||
spec = importlib.util.find_spec(".".join((*processed, modname))) | ||
except ValueError: | ||
jacobtylerwalls marked this conversation as resolved.
Show resolved
Hide resolved
|
||
spec = None | ||
|
||
if ( | ||
spec | ||
and spec.loader # type: ignore[comparison-overlap] # noqa: E501 | ||
|
@@ -187,28 +217,6 @@ | |
except ValueError: | ||
pass | ||
|
||
if submodule_path is not None: | ||
search_paths = list(submodule_path) | ||
else: | ||
search_paths = sys.path | ||
|
||
suffixes = (".py", ".pyi", importlib.machinery.BYTECODE_SUFFIXES[0]) | ||
for entry in search_paths: | ||
package_directory = os.path.join(entry, modname) | ||
for suffix in suffixes: | ||
package_file_name = "__init__" + suffix | ||
file_path = os.path.join(package_directory, package_file_name) | ||
if cached_os_path_isfile(file_path): | ||
return ModuleSpec( | ||
name=modname, | ||
location=package_directory, | ||
type=ModuleType.PKG_DIRECTORY, | ||
) | ||
for suffix, type_ in ImportlibFinder._SUFFIXES: | ||
file_name = modname + suffix | ||
file_path = os.path.join(entry, file_name) | ||
if cached_os_path_isfile(file_path): | ||
return ModuleSpec(name=modname, location=file_path, type=type_) | ||
return None | ||
|
||
def contribute_to_path( | ||
|
Uh oh!
There was an error while loading. Please reload this page.