python / python/cpython

Builds Without HAVE_DYNAMIC_LOADING Set Still Expose Features and API Related to Dynamic Modules

Open
#122,950 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.14 extension-modules interpreter-core topic-importlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

When CPython is built without HAVE_DYNAMIC_LOADING set, we currently leave out a small handful of code in Python/import.c and Python/importdl.c. However, there is a bunch more that should probably be excluded (via #ifdef HAVE_DYNAMIC_LOADING):

  • some functions and constants in Python/importdl.c and Include/internal/pycore_importdl.h
  • some functions, constants, and state in Python/import.c and Include/internal/pycore_import.h
  • some code in Lib/importlib/_bootstrap_external.py
  • maybe some code in Objects/moduleobject.c
  • builds for Modules/Setup.stdlib
  • checks in Tools/build/check_extension_modules.py
  • modules listed by Tools/build/generate_stdlib_module_names.py

(Also see gh-122907.)

Getting this all correct would probably take a fair amount of effort. Perhaps the big question is would it be worth addressing all these cases?

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the dynamic-loading paths named in Python/import.c, Python/importdl.c, Include/internal/pycore_importdl.h, Include/internal/pycore_import.h, Lib/importlib/_bootstrap_external.py, and Objects/moduleobject.c, along with the listed Tools/build scripts and Modules/Setup.stdlib. Compare behavior when HAVE_DYNAMIC_LOADING is unset, considering gh-122907, and determine the complete scope before defining what consistent exclusion of dynamic-module APIs and features would mean.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.