Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

_get_nested_attr returning None due to missing a return in the general case #1053

@andreykramer

Description

@andreykramer

I noticed that the old_state variable of make_functional.py::FunctionalModuleWithBuffers::forward is always full of None elements. Digging a bit I saw that there is no return in the general case of _get_nested_attr

    if len(names) == 1:
        return getattr(obj, names[0])
    else:
        # No return here
        _get_nested_attr(getattr(obj, names[0]), names[1:])

So the outermost call is always returning None when len(names) > 1. If I'm right and this is a bug what implications does it have? For instance, the "Remove the loaded state on self.stateless_model" step surely wouldn't be doing what it's supposed to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionableIt is clear what should be done for this issuesmall

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions