python / python/mypy

Infinite recursion in generate_c_type_stub when an a type's attr has the same name as its parent

Aperta
#11,989 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

crash topic-stubgen
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug Report

While trying out stubgen for the first time on a C(++)-extension module I get a 'RecursionError: maximum recursion depth exceeded' due to infinite recursion.

To Reproduce

conda create --name stubs python=3.9 --channel conda-forge --channel bioconda
conda install pyopenms mypy
stubgen -p pyopenms

Expected Behavior

No error. If I add a if (attr != class_name): here
https://github.com/python/mypy/blob/master/mypy/stubgenc.py#L361

it runs through.

BTW: You might also need to increase the timeout here: https://github.com/python/mypy/blob/master/mypy/moduleinspect.py#L165
No clue why it is so short.

Actual Behavior

Traceback (most recent call last):
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 367, in generate_c_type_stub
    generate_c_type_stub(module, attr, value, types, imports=imports, sigs=sigs,
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 367, in generate_c_type_stub
    generate_c_type_stub(module, attr, value, types, imports=imports, sigs=sigs,
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 367, in generate_c_type_stub
    generate_c_type_stub(module, attr, value, types, imports=imports, sigs=sigs,
  [Previous line repeated 989 more times]
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 356, in generate_c_type_stub
    generate_c_function_stub(module, attr, value, methods, imports=imports,
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubgenc.py", line 182, in generate_c_function_stub
    inferred = infer_sig_from_docstring(docstr, name)
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/site-packages/mypy/stubdoc.py", line 232, in infer_sig_from_docstring
    for token in tokens:
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/tokenize.py", line 525, in _tokenize
    pseudomatch = _compile(PseudoToken).match(line, pos)
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/tokenize.py", line 99, in _compile
    return re.compile(expr, re.UNICODE)
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/re.py", line 292, in _compile
    flags = flags.value
  File "/Users/pfeuffer/miniconda3/envs/pyopenms_stubs/lib/python3.9/types.py", line 178, in __get__
    return self.fget(instance)
RecursionError: maximum recursion depth exceeded

Your Environment

  • Mypy version used: 0.931
  • Mypy command-line flags: -p pyopenms
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.9.9
  • Operating system and version: macOS 10.15.4

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in mypy/stubgenc.py intorno a generate_c_type_stub alla riga indicata, quindi riproduci il problema con stubgen -p pyopenms usando l’ambiente indicato. Traccia come viene gestito un attributo con lo stesso nome del suo elemento padre; il lavoro è completato quando il comando termina senza RecursionError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
tooling
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
50/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.