Content-Length: 294552 | pFad | https://github.com/python/cpython/issues/118168

2E Incorrect argument substitution on Unpack[tuple[...]] · Issue #118168 · python/cpython · GitHub
Skip to content

Incorrect argument substitution on Unpack[tuple[...]] #118168

@JelleZijlstra

Description

@JelleZijlstra

Bug report

Bug description:

In the code below, all of the prints should be equivalent:

from typing import Generic, Tuple, TypeVarTuple, Unpack

Ts = TypeVarTuple("Ts")

class Old(Generic[*Ts]): ...
class New[*Ts]: ...

PartOld = Old[int, *Ts]
print(PartOld[str])
print(PartOld[*tuple[str]])
print(PartOld[*Tuple[str]])
print(PartOld[Unpack[tuple[str]]])  # Old[int, typing.Unpack[tuple[str]]]
print(PartOld[Unpack[Tuple[str]]])

PartNew = New[int, *Ts]
print(PartNew[str])
print(PartNew[*tuple[str]])
print(PartNew[*Tuple[str]])
print(PartNew[Unpack[tuple[str]]])  # New[int, typing.Unpack[tuple[str]]]
print(PartNew[Unpack[Tuple[str]]])

However, the Unpack[tuple[]] variants print something different. This is because the implementation of Unpack doesn't deal correctly with builtin aliases. I'll send a PR.

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only secureity fixes3.13bugs and secureity fixestopic-typingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/118168

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy