library symtable.SymbolTable.is_nested() description differs from Cpython implementation.
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 20/100
- Tipo de issue
- Documentação
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Stack de tecnologia
- python
- Domínio
- documentation
Direção de pesquisa
Revise primeiro o PR vinculado gh-151901, depois compare o symtable e inspecione a documentação com o comportamento declarado do CPython e a flag CO_NESTED. A issue deixa a resolução em aberto: alinhar a implementação e adicionar compiler tests, ou corrigir a documentação e possivelmente depreciar o recurso.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
The documentation says
is_nested()
Return True if the block is a nested class or function.
The cpython implementation of symtable.c sets the corresponding flag only if the block is nested somewhere inside a function. This would include, for example, a scope inside a class inside a function.
Thus
def f(): # false
def g(): # true
def h(): # true
class C: # true
class B: # true
def h(): # true
class C: # true
class A: # false
def g(): # false !!
def h(): # true
class C: # true
class B: # false !!
def h(): # false !!
class C: # false !!
The value is the same as the CO_NESTED bit in the code object's co_flags member.
The flag is also documented (similarly incorrectly) in the inspect module documentation.
I would recommend deprecating this feature. The documentation for co_flags says that
bits 0x10 and 0x1000 were used in earlier versions of Python.
0x10 is the CO_NESTED bit. I would guess that nobody uses CO_NESTED or SymbolTable.is_nested().
Alternatives:
- Change the behavior in Cpython to agree with the documentation. A class nested in another scope should also have CO_NESTED set. Make a test case for the compiler, to ensure that other implementations follow the same definition.
- Correct the documentation for symtable and inspect modules. Possibly also deprecate the feature.
Linked PRs
- gh-151901
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Merge médio
- 1d 9h
- PRs com merge (30d)
- 558
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python/cpython
-
docs pending
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
stdlib type-feature
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
stdlib type-feature
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
build type-bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
stdlib topic-email type-feature
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Todas as issues de python/cpython
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
zostera/django-bootstrap4#894 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
use-agent-os/agent-os#3276 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
NousResearch/hermes-agent#117848 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
zilliztech/memsearch#759 ·