Skip to content

Segmentation fault with custom TypeTraverserVisitor #8360

@mkurnikov

Description

@mkurnikov

I'm trying to copy methods from one class into the other, need to add some imports to other class' module.
https://github.com/django/django/blob/b9cf764be62e77b4777b3a75ec256f6209a57671/django/db/models/manager.py#L101

I'd like to use custom TypeTraverserVisitor for that

signature_node: FuncDef

def import_symbol_from_source(name: str) -> None:
    if name in source_symbols['__builtins__'].node.names:
        return
    sym = source_symbols[name].copy()
    self.semanal_api.add_imported_symbol(name, sym, context=self.semanal_api.cur_mod_node)

class UnimportedTypesVisitor(TypeTraverserVisitor):
    def visit_instance(self, t: Instance) -> None:
        super().visit_instance(t)
        if isinstance(t.type, FakeInfo):
            return
        type_name = t.type.name
        sym = currently_imported_symbols.get(type_name)
        if sym is None:
            import_symbol_from_source(type_name)

signature_node.type.accept(UnimportedTypesVisitor())

Compiled version of mypy segfaults for me, when I'm trying to use code like this. The plain Python version runs just fine.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy