Skip to content
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

Fix some importlib usages #2123

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 1 addition & 6 deletions isapi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
_DEFAULT_ENABLE_DIR_BROWSING = False
_DEFAULT_ENABLE_DEFAULT_DOC = False

_extensions = [ext for ext, _, _ in importlib.machinery.EXTENSION_SUFFIXES]
is_debug_build = "_d.pyd" in _extensions

this_dir = os.path.abspath(os.path.dirname(__file__))


Expand Down Expand Up @@ -504,9 +501,7 @@ def DeleteExtensionFileRecords(params, options):


def CheckLoaderModule(dll_name):
suffix = ""
if is_debug_build:
suffix = "_d"
suffix = "_d" if "_d.pyd" in importlib.machinery.EXTENSION_SUFFIXES else ""
template = os.path.join(this_dir, "PyISAPI_loader" + suffix + ".dll")
if not os.path.isfile(template):
raise ConfigurationError("Template loader '%s' does not exist" % (template,))
Expand Down
2 changes: 1 addition & 1 deletion win32/Lib/win32serviceutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# when things go wrong - eg, not enough permissions to hit the
# registry etc.

import importlib
import importlib.machinery
Copy link
Collaborator Author

@Avasam Avasam Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See python/typeshed#10746 (comment) as to why importing directly from importlib shouldn't be relied on for importlib.machinery, importlib.util and importlib.abc. Mypy & Pyright (see #2102) will also catch this.

import os
import sys
import warnings
Expand Down