[3.13] gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952) (#122984)

gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952)

As of 529a160 (gh-118204), building with HAVE_DYNAMIC_LOADING stopped working.  This is a minimal fix just to get builds working again.  There are actually a number of long-standing deficiencies with HAVE_DYNAMIC_LOADING builds that need to be resolved separately.
(cherry picked from commit ee1b8ce26e)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-12-03 17:46:30 +01:00 committed by GitHub
parent ae3f347dc0
commit dddea7c232
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 32 additions and 12 deletions

View file

@ -27,6 +27,7 @@ import re
import sys
import sysconfig
import warnings
import _imp
from importlib._bootstrap import _load as bootstrap_load
from importlib.machinery import BuiltinImporter, ExtensionFileLoader, ModuleSpec
@ -154,6 +155,11 @@ class ModuleChecker:
self.notavailable = []
def check(self):
if not hasattr(_imp, 'create_dynamic'):
logger.warning(
('Dynamic extensions not supported '
'(HAVE_DYNAMIC_LOADING not defined)'),
)
for modinfo in self.modules:
logger.debug("Checking '%s' (%s)", modinfo.name, self.get_location(modinfo))
if modinfo.state == ModuleState.DISABLED:
@ -415,6 +421,9 @@ class ModuleChecker:
logger.error("%s failed to import: %s", modinfo.name, e)
raise
except Exception as e:
if not hasattr(_imp, 'create_dynamic'):
logger.warning("Dynamic extension '%s' ignored", modinfo.name)
return
logger.exception("Importing extension '%s' failed!", modinfo.name)
raise