Skip to content

repo.submodule('sort') returns reference to IterableList.sort() method, not Submodule instance #1091

Closed as not planned

Description

@ryan-williams

Check out toy example repo w/ 2 submodules (named generate-random-ints and sort):

git clone --recurse-submodules https://gitlab.com/gsmo/examples/submodule-demo.git
cd submodule-demo
git checkout e6f6d8f
git submodule update
python

In Python REPL:

import git
repo = git.Repo()
repo.submodule('sort')
# <built-in method sort of IterableList object at 0x1058a7360>
repo.submodule('generate-random-ints')
# git.Submodule(name=generate-random-ints, path=generate-random-ints, url=https://gitlab.com/gsmo/examples/submodules/generate-random-ints.git, branch_path=refs/heads/master)

The submodule named sort can't be retrieved, as its name is shadowed by the IterableList.sort method.

Activity

  1. changed the title [-]`repo.submodule['sort']` returns reference to sort() method, not Submodule instance[/-] [+]`repo.submodule('sort')` returns reference to sort() method, not Submodule instance[/+] on Nov 26, 2020
  2. changed the title [-]`repo.submodule('sort')` returns reference to sort() method, not Submodule instance[/-] [+]`repo.submodule('sort')` returns reference to IterableList.sort() method, not Submodule instance[/+] on Nov 26, 2020
  3. Byron commented on Nov 27, 2020

    @Byron
    Member

    Thanks a lot for taking the time to illustrate the issue and for making it reproducible!

    It looks like in order to fix this, one would have to fix the indexex access of IterableList to make this kind of code work across the board.
    As these are used in many places, similar issues would be present in other places, too. References come to mind.

  4. added theissue type on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions