GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — site: .pth import lines can no longer read the 'fullname' local variable · Issue #156404 · python/cpython

site: .pth import lines can no longer read the 'fullname' local variable #156404

New issue
Copy link
New issue
Copy link
Closed
Closed
site: .pth import lines can no longer read the 'fullname' local variable#156404
Copy link
Assignees
warsaw
Labels
3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@arcivanov
arcivanov
opened on Aug 26, 2026
Issue body actions

Bug report

Python 3.15 implements PEP 829 and moved .pth handling out of site.addpackage() into site.StartupState._exec_imports(). import lines in .pth files are still exec()'d, but now from a different frame, and the local variable holding the path of the .pth file being processed was renamed from fullname to filename. Any .pth file generated before 3.15 that reads fullname now raises NameError on every interpreter startup.

Reproducer

import os, site, tempfile

with tempfile.TemporaryDirectory() as d:
    with open(os.path.join(d, "foo.pth"), "w") as f:
        f.write("import sys; print(fullname)\n")
    site.addpackage(d, "foo.pth", set())

On 3.14 this prints the path of the .pth file. On 3.15 and on main:

Error in import line from /tmp/tmp3kbbbxtg/foo.pth: import sys; print(fullname)
  Traceback (most recent call last):
    File "Lib/site.py", line 533, in _exec_imports
      exec(line)
      ~~~~^^^^^^
    File "<string>", line 1, in <module>
  NameError: name 'fullname' is not defined. Did you mean: 'filename'?

Real-world impact

Every wheel built by wheel-axle before 0.0.13 installs a .pth file containing import wheel_axle.runtime; wheel_axle.runtime.finalize(fullname);, and there are published wheels in the wild carrying that line. The interpreter still starts, because site prints the traceback and continues, but the post-install hook never runs, so the symlinks the wheel declares are never created, and the error is printed again on every single startup because the .pth is never consumed. Downstream tracking issue: karellen/wheel-axle#38

PEP 829 keeps executing .pth import lines through 3.17, so this is not a case where the old mechanism has been retired. The lines still run; they just run against a frame that no longer exposes the name they were written against.

Suggested fix

This is the same class of regression as gh-149671, fixed in f7ab7c4 by injecting the sitedir local into _exec_imports() for compatibility with the -nspkg.pth files generated by setuptools. fullname needs identical treatment, immediately below the existing sitedir shim:

# Inject 'fullname' local variable in the current frame for
# compatibility with Python 3.14, where the path of the ".pth"
# file being processed was available to import lines under that
# name.
fullname = filename

I have this working locally against 3.15 with a regression test alongside test_sitedir_variable, and will open a PR.

Your environment

  • CPython versions tested on: 3.15 (v3.15.0rc1-86-gd0484ab51a7), main
  • Operating system and architecture: Linux x86-64

Linked PRs

  • gh-156404: Restore the 'fullname' variable for .pth import lines #156405
  • gh-156404: Restore the 'fullname' variable for .pth import lines #156406
  • [3.15] gh-156404: Restore the 'fullname' variable for .pth import lines (GH-156406) #156431

Activity

  1. arcivanov
    added 2 commits that reference this issue on Aug 26, 2026

    pythongh-156404: Restore the 'fullname' variable for .pth import lines

    0677575

    pythongh-156404: Restore the 'fullname' variable for .pth import lines

    909b4f2
  2. aisk
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.15bugs and security fixesbugs and security fixes
    on Aug 26, 2026
  3. warsaw
    self-assigned this
    on Aug 26, 2026
  4. warsaw
    added a commit that references this issue on Aug 26, 2026

    Merge branch 'main' into pythongh-156404-pth-fullname

    c2cedb7
  5. warsaw commented on Aug 26, 2026

    @warsaw
    warsaw
    on Aug 26, 2026
    Member
    More actions

    Thanks for the bug report and PR. We can keep this name binding as long as we're keeping the sitedir name binding.

    Reacted by Arcadiy Ivanov
  6. warsaw
    added a commit that references this issue on Aug 26, 2026

    gh-156404: Restore the 'fullname' variable for .pth import lines (#15…

    7f3d09b
  7. hugovk
    added a commit that references this issue on Aug 27, 2026

    [3.15] gh-156404: Restore the 'fullname' variable for .pth import lin…

    224db4e
  8. hugovk
    closed this as completedon Aug 27, 2026
  9. clin1234
    added a commit that references this issue on Aug 27, 2026

    pythongh-156404: Restore the 'fullname' variable for .pth import lines (

    2132406
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @warsaw
    warsaw

Labels

3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.