Fedora Account System
Red Hat Associate
Red Hat Customer
Description of problem: After the Python 3.15 update in Rawhide every interpreter startup prints a traceback from the legacy google-namespace .pth file shipped in python3-protobuf3: Error in import line from /usr/lib/python3.15/site-packages/protobuf-3.19.6-py3.15-nspkg.pth: import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('google',));importlib = __import__('importlib.util');__import__('importlib.machinery');m = sys.modules.setdefault('google', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('google', [os.path.dirname(p)])));m = m or sys.modules.setdefault('google', types.ModuleType('google'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p) Traceback (most recent call last): File "<frozen site>", line 533, in _exec_imports File "<string>", line 1, in <module> KeyError: "local variable ''sitedir'' is not defined" The line is setuptools' pkg_resources-namespace stub; it gets the site dir via sys._getframe(1).f_locals['sitedir']. Through 3.14 site.addpackage(sitedir, ...) ran the line itself, so frame 1 was addpackage and 'sitedir' was its parameter. 3.15 rewrote site.py (PEP 829, gh-148641/gh-150228) and import lines now run inside StartupState._exec_imports(), which has no 'sitedir', hence the KeyError. The "local variable ... is not defined" text is the PEP 667 fast-locals-proxy KeyError from 3.13. It's non-fatal, site.py catches it and continues, but it prints at every python3 startup including from scriptlets that run python3. I first saw it in the fedora-third-party triggers, but those complete fine and it isn't specific to them. Import lines in .pth are deprecated by PEP 829 and the stub depends on a private site internal that was never guaranteed, so the fix belongs in the package, not CPython. Version-Release number of selected component (if applicable): protobuf3-3.19.6-64.fc45 python3-3.15.0~b2-2.fc45 How reproducible: Always Steps to Reproduce: 1. Rawhide with python3-3.15.0~b2 and python3-protobuf3 installed 2. python3 -c '' Actual results: A traceback on stderr at every startup (Error in import line ... KeyError ...'sitedir'...). Expected results: No output. Additional info: Fix: drop the legacy namespace_packages and ship as a PEP 420 native namespace (no *-nspkg.pth generated). Afterwards python3 -c '' is silent and import google.protobuf still works. The google namespace is shared with other packages (google-api-*, grpcio, ...), so check that it still resolves across all co-installed providers after the switch. Refs: gh-148641, gh-150228 (Barry Warsaw); What's New in Python 3.15, site.StartupState. Reproducible: Always
See example: https://src.fedoraproject.org/rpms/python-paste/pull-request/11
FEDORA-2026-f49690e24d (protobuf3-3.19.6-65.fc45) has been submitted as an update to Fedora 45. https://bodhi.fedoraproject.org/updates/FEDORA-2026-f49690e24d
FEDORA-2026-f49690e24d (protobuf3-3.19.6-65.fc45) has been pushed to the Fedora 45 stable repository. If problem still persists, please make note of it in this bug report.