pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/ee1b8ce26e700350e47a5f65201097121c41912e

97560d244c08.css" /> gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952) · python/cpython@ee1b8ce · GitHub
Skip to content

Commit ee1b8ce

Browse files
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.
1 parent 5f68511 commit ee1b8ce

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

Include/internal/pycore_importdl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ extern int _Py_ext_module_loader_info_init_for_core(
5656
extern int _Py_ext_module_loader_info_init_for_builtin(
5757
struct _Py_ext_module_loader_info *p_info,
5858
PyObject *name);
59+
#ifdef HAVE_DYNAMIC_LOADING
5960
extern int _Py_ext_module_loader_info_init_from_spec(
6061
struct _Py_ext_module_loader_info *info,
6162
PyObject *spec);
63+
#endif
6264

6365
/* The result from running an extension module's init function. */
6466
struct _Py_ext_module_loader_result {
@@ -87,9 +89,11 @@ extern void _Py_ext_module_loader_result_apply_error(
8789

8890
/* The module init function. */
8991
typedef PyObject *(*PyModInitFunction)(void);
92+
#ifdef HAVE_DYNAMIC_LOADING
9093
extern PyModInitFunction _PyImport_GetModInitFunc(
9194
struct _Py_ext_module_loader_info *info,
9295
FILE *fp);
96+
#endif
9397
extern int _PyImport_RunModInitFunc(
9498
PyModInitFunction p0,
9599
struct _Py_ext_module_loader_info *info,

Lib/importlib/_bootstrap_external.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,14 +1523,14 @@ def _get_supported_file_loaders():
15231523
15241524
Each item is a tuple (loader, suffixes).
15251525
"""
1526-
if sys.platform in {"ios", "tvos", "watchos"}:
1527-
extension_loaders = [(AppleFrameworkLoader, [
1528-
suffix.replace(".so", ".fwork")
1529-
for suffix in _imp.extension_suffixes()
1530-
])]
1531-
else:
1532-
extension_loaders = []
1533-
extension_loaders.append((ExtensionFileLoader, _imp.extension_suffixes()))
1526+
extension_loaders = []
1527+
if hasattr(_imp, 'create_dynamic'):
1528+
if sys.platform in {"ios", "tvos", "watchos"}:
1529+
extension_loaders = [(AppleFrameworkLoader, [
1530+
suffix.replace(".so", ".fwork")
1531+
for suffix in _imp.extension_suffixes()
1532+
])]
1533+
extension_loaders.append((ExtensionFileLoader, _imp.extension_suffixes()))
15341534
source = SourceFileLoader, SOURCE_SUFFIXES
15351535
bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES
15361536
return extension_loaders + [source, bytecode]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Building with ``HAVE_DYNAMIC_LOADING`` now works as well as it did in 3.12.
2+
Existing deficiences will be addressed separately.
3+
(See https://github.com/python/cpython/issues/122950.)

Python/importdl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
#include "pycore_pystate.h"
99
#include "pycore_runtime.h"
1010

11+
#include "pycore_importdl.h"
12+
1113
/* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is
1214
supported on this platform. configure will then compile and link in one
1315
of the dynload_*.c files, as appropriate. We will call a function in
1416
those modules to get a function pointer to the module's init function.
1517
*/
1618
#ifdef HAVE_DYNAMIC_LOADING
1719

18-
#include "pycore_importdl.h"
19-
2020
#ifdef MS_WINDOWS
2121
extern dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
2222
const char *shortname,
@@ -28,6 +28,8 @@ extern dl_funcptr _PyImport_FindSharedFuncptr(const char *prefix,
2828
const char *pathname, FILE *fp);
2929
#endif
3030

31+
#endif /* HAVE_DYNAMIC_LOADING */
32+
3133

3234
/***********************************/
3335
/* module info to use when loading */
@@ -205,6 +207,7 @@ _Py_ext_module_loader_info_init_for_core(
205207
return 0;
206208
}
207209

210+
#ifdef HAVE_DYNAMIC_LOADING
208211
int
209212
_Py_ext_module_loader_info_init_from_spec(
210213
struct _Py_ext_module_loader_info *p_info,
@@ -226,6 +229,7 @@ _Py_ext_module_loader_info_init_from_spec(
226229
Py_DECREF(filename);
227230
return err;
228231
}
232+
#endif /* HAVE_DYNAMIC_LOADING */
229233

230234

231235
/********************************/
@@ -372,6 +376,7 @@ _Py_ext_module_loader_result_apply_error(
372376
/* getting/running the module init function */
373377
/********************************************/
374378

379+
#ifdef HAVE_DYNAMIC_LOADING
375380
PyModInitFunction
376381
_PyImport_GetModInitFunc(struct _Py_ext_module_loader_info *info,
377382
FILE *fp)
@@ -406,6 +411,7 @@ _PyImport_GetModInitFunc(struct _Py_ext_module_loader_info *info,
406411

407412
return (PyModInitFunction)exportfunc;
408413
}
414+
#endif /* HAVE_DYNAMIC_LOADING */
409415

410416
int
411417
_PyImport_RunModInitFunc(PyModInitFunction p0,
@@ -513,5 +519,3 @@ _PyImport_RunModInitFunc(PyModInitFunction p0,
513519
p_res->err = &p_res->_err;
514520
return -1;
515521
}
516-
517-
#endif /* HAVE_DYNAMIC_LOADING */

Tools/build/check_extension_modules.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import sys
2828
import sysconfig
2929
import warnings
30+
import _imp
3031

3132
from importlib._bootstrap import _load as bootstrap_load
3233
from importlib.machinery import BuiltinImporter, ExtensionFileLoader, ModuleSpec
@@ -153,6 +154,11 @@ def __init__(self, cross_compiling: bool = False, strict: bool = False):
153154
self.notavailable = []
154155

155156
def check(self):
157+
if not hasattr(_imp, 'create_dynamic'):
158+
logger.warning(
159+
('Dynamic extensions not supported '
160+
'(HAVE_DYNAMIC_LOADING not defined)'),
161+
)
156162
for modinfo in self.modules:
157163
logger.debug("Checking '%s' (%s)", modinfo.name, self.get_location(modinfo))
158164
if modinfo.state == ModuleState.DISABLED:
@@ -414,6 +420,9 @@ def check_module_import(self, modinfo: ModuleInfo):
414420
logger.error("%s failed to import: %s", modinfo.name, e)
415421
raise
416422
except Exception as e:
423+
if not hasattr(_imp, 'create_dynamic'):
424+
logger.warning("Dynamic extension '%s' ignored", modinfo.name)
425+
return
417426
logger.exception("Importing extension '%s' failed!", modinfo.name)
418427
raise
419428

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

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