From 9ca229105956a22db7c811a10d9971bb781a5518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Wed, 3 Jun 2026 12:28:51 -0700 Subject: [PATCH 1/2] gh-150886: Remove unused importlib._bootstrap._object_name Introduced in GH-23469 (bpo-26131, "Deprecate usage of load_module()") to render an object's qualified name inside the load_module() deprecation warnings. Orphaned by gh-142205 (GH-97850, "Remove all uses and definitions of load_module() from importlib"), which deleted the warning-building call sites f"{_object_name(spec.loader)}.exec_module() not found; ..." and left the helper with no caller. A word-boundary search across Lib, Modules, Python, Objects and Include finds zero references outside its own definition, and a GitHub code search finds no downstream importers. The frozen importlib was regenerated; importlib._bootstrap._object_name no longer exists at runtime and the full test_importlib suite passes. --- Lib/importlib/_bootstrap.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 06dc45d71d7ca4a..eb1686a5c8217c6 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -20,12 +20,6 @@ # reference any injected objects! This includes not only global code but also # anything specified at the class level. -def _object_name(obj): - try: - return obj.__qualname__ - except AttributeError: - return type(obj).__qualname__ - # Bootstrap-related code ###################################################### # Modules injected manually by _setup() From e3a8519d3045f010c332ddcc5990c40efb4bb434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Wed, 3 Jun 2026 14:59:11 -0700 Subject: [PATCH 2/2] gh-150886: Add NEWS entry for _object_name removal --- .../Library/2026-06-03-21-59-11.gh-issue-150886.r2c25g.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-06-03-21-59-11.gh-issue-150886.r2c25g.rst diff --git a/Misc/NEWS.d/next/Library/2026-06-03-21-59-11.gh-issue-150886.r2c25g.rst b/Misc/NEWS.d/next/Library/2026-06-03-21-59-11.gh-issue-150886.r2c25g.rst new file mode 100644 index 000000000000000..b220b63cfdb4ab5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-03-21-59-11.gh-issue-150886.r2c25g.rst @@ -0,0 +1,4 @@ +Remove the private, undocumented function +``importlib._bootstrap._object_name()``. It had no caller after +``load_module()`` and its deprecation warnings were removed from +:mod:`importlib`.