Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Symbol table for type parameter (PEP 695) raises AssertionError on get_type() #110045

Closed
Assignees
JelleZijlstra
Labels
3.12only security fixes3.13bugs and security fixestopic-typingtype-bugAn unexpected behavior, bug, or error
@wookayin

Description

@wookayin

Bug report

Bug description:

Tested with CPython 3.12.0rc3

importsymtabledeffoo[T]():return"bar"t_mod=symtable.symtable("""\def foo[T]():    return "bar"""",'?','exec')t_T=t_mod.get_children()[0]print(t_T.get_type())
Traceback (most recent call last):   File ".../bug_symtable.py", line 12, in <module>     print(t_T.get_type())           ^^^^^^^^^^^^^^   File ".../3.12.0rc3/lib/python3.12/symtable.py", line 74, in get_type     assert self._table.type in (1, 2, 3), \ AssertionError: unexpected type: 6 [Finished in 1 seconds with code 1]

The symbol table for type parameters (generic) seem to have a new type, but it appears that thesymtable implementation was not updated accordingly. Also there is no_symtable.TYPE_* constant for type code 6 (see_symtable).

https://github.com/python/cpython/blob/3.12/Lib/symtable.py#L62-L75
https://github.com/python/cpython/blob/main/Lib/symtable.py#L62-L75

There are new block types introduced by PEP 695https://github.com/python/cpython/blob/3.12/Include/internal/pycore_symtable.h#L13-L23

- 0: FunctionBlock- 1: ClassBlock- 2: ModuleBlock    // Used for annotations 'from __future__ import annotations' - 3: AnnotationBlock    // Used for generics and type aliases. These work mostly like functions    // (see PEP 695 for details). The three different blocks function identically;    // they are different enum entries only so that error messages can be more    // precise.- 4: TypeVarBoundBlock- 5: TypeAliasBlock- 6: TypeParamBlock

https://github.com/python/cpython/blob/3.12/Include/internal/pycore_symtable.h#L13-L23

Hope this can be fixed by the 3.12 GA release.

CPython versions tested on:

3.12.0rc3

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security 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


    [8]ページ先頭

    ©2009-2025 Movatter.jp