Skip to content

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

Description

@jpfeuffer

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions