Skip to content

TypeError: Protocols cannot be instantiated #1332

Open
@jessielaf

Description

@jessielaf

I am having a issue with getting the date from a git commit. I keep getting this error:

Traceback (most recent call last):
  File "/code/manage.py", line 19, in <module>
    main()
  File "/code/manage.py", line 15, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/code/commits/management/commands/scan_commits.py", line 35, in handle
    self.create_commits_branch(project, branch)
  File "/code/commits/management/commands/scan_commits.py", line 57, in create_commits_branch
    date=datetime.fromtimestamp(git_commit.committed_date),
  File "/usr/local/lib/python3.9/site-packages/gitdb/util.py", line 253, in __getattr__
    self._set_cache_(attr)
  File "/usr/local/lib/python3.9/site-packages/git/objects/commit.py", line 199, in _set_cache_
    self._deserialize(BytesIO(stream.read()))
  File "/usr/local/lib/python3.9/site-packages/git/objects/commit.py", line 528, in _deserialize
    self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id << 12, '')
  File "/usr/local/lib/python3.9/site-packages/git/objects/tree.py", line 215, in __init__
    super(Tree, self).__init__(repo, binsha, mode, path)
  File "/usr/local/lib/python3.9/site-packages/git/objects/base.py", line 168, in __init__
    super(IndexObject, self).__init__(repo, binsha)
  File "/usr/local/lib/python3.9/site-packages/git/objects/base.py", line 56, in __init__
    super(Object, self).__init__()
  File "/usr/local/lib/python3.9/typing.py", line 1083, in _no_init
    raise TypeError('Protocols cannot be instantiated')
TypeError: Protocols cannot be instantiated

I get this error with the python 3.9 in docker. Using version 3.1.20 of GitPython.

Activity

jakob-keller

jakob-keller commented on Sep 2, 2021

@jakob-keller

I am experiencing the same issue since upgrading to GitPython 3.1.20 and Python 3.9.7. Downgrading GitPython to 3.1.18 fixed it for me.

This could be related to bc37d15

msbuhl

msbuhl commented on Sep 3, 2021

@msbuhl

I got this error with Python 3.9.7
A downgrade to Python 3.9.6 fixed it for me

Using GitPython 3.1.20

assigned and unassigned on Sep 5, 2021
Yobmod

Yobmod commented on Sep 9, 2021

@Yobmod
Contributor

Hi,
Yeah, this is caused by a change in how python enforces protocol initilisation.
But it should also be worked-around in main already ( #1318) - it worked for 3.10.0, just have to test 3.9.7.
3.9.7 tests passed, So will be fixed on next release.

1Mark

1Mark commented on Nov 12, 2021

@1Mark

I had the same issue using python3.9.7 and GitPython 3.1.19. After upgrading to 3.1.24 the error went away.

@Yobmod can we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Byron@1Mark@Yobmod@jessielaf@jakob-keller

      Issue actions

        TypeError: Protocols cannot be instantiated · Issue #1332 · gitpython-developers/GitPython