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 — annotationlib - evaluating forward references in STRING format can 'leak' internal names · Issue #148680 · python/cpython

annotationlib - evaluating forward references in STRING format can 'leak' internal names #148680

New issue
Copy link
New issue
Copy link
Closed
Closed
annotationlib - evaluating forward references in STRING format can 'leak' internal names#148680
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@DavidCEllis
DavidCEllis
opened on Apr 17, 2026
Issue body actions

Bug report

Bug description:

If a ForwardRef object needs internal names to store values of known objects these internal names currently replace the type_repr of the objects they represent when the ForwardRef is evaluated as Format.STRING or when looking at the repr.

If it was just the repr I'd probably put this as a feature request but as it makes the STRING format arguably 'wrong' I think it should be considered a bug.

from annotationlib import get_annotations, Format

class Example:
    a: ref | str

ann = get_annotations(Example, format=Format.FORWARDREF)['a']
print(ann)
print(ann.evaluate(format=Format.STRING))

On 3.14 or Main:

ForwardRef('ref | __annotationlib_name_1__', is_class=True, owner=<class '__main__.Example'>)
ref | __annotationlib_name_1__

Expected:

ForwardRef('ref | str', is_class=True, owner=<class '__main__.Example'>)
ref | str

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

No response

Linked PRs

  • gh-148680: Replace internal names with type_reprs of objects in string representations of ForwardRef #148682
  • [3.14] gh-148680: Replace internal names with type_reprs of objects in string representations of ForwardRef (GH-148682) #148913

Activity

  1. DavidCEllis
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 17, 2026
  2. StanFromIreland
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Apr 17, 2026
  3. picnixz
    added
    topic-typing
    on Apr 19, 2026
  4. JelleZijlstra
    added 2 commits that reference this issue on Apr 23, 2026

    gh-148680: Replace internal names with type_reprs of objects in strin…

    158dbbb

    [3.14] gh-148680: Replace internal names with type_reprs of objects i…

    b6a7212
  5. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-148680: Replace internal names with type_reprs of objects in…

    2848310
  6. DavidCEllis
    closed this as completedon Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-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 01402520 — 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.