GitPython: Issues with AutoInterrupt in conjunction with sys.exit on python 3.5

The destructor of the cmd class (actually AutoInterrupt) seems to throw some errors using python 3.5 on Arclinux:

Exception ignored in: <bound method Git.AutoInterrupt.__del__ of <git.cmd.Git.AutoInterrupt object at 0x7f7c2b101d68>>
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/git/cmd.py", line 294, in __del__
TypeError: 'NoneType' object is not callable
Exception ignored in: <bound method Git.AutoInterrupt.__del__ of <git.cmd.Git.AutoInterrupt object at 0x7f7c2b101cc0>>
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/git/cmd.py", line 294, in __del__
TypeError: 'NoneType' object is not callable

It seems this error is triggered by a call to sys.exit(0) at the end of my script, since it doesn’t appear if I comment it out. However I couldn’t reproduce this behavior with python 2.7, here sys.exit(0) seems to be working with the module correctly.

What I do is simply clone a repo, add some files commit and push them to a remote.

...
repo = Repo.clone_from(target_git_path, target_temp_dir)
...
repo.index.add([file])
...
repo.index.commit('Initial commit')
...
refspec='refs/heads/{0}:refs/heads/{0}'.format(repo.active_branch) # this will fix error if user has set "push.default = matching"
repo.remotes.origin.push(refspec=refspec)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (19 by maintainers)

Most upvoted comments

I’m pondering if the cmd code should be ripped out and replaced en-mass. Given the set of requirements that the cmd code has the current implementation is looking far to complex and hard to modify.

We now know that it needs to:

  • run a git command
  • allow all stdout to be processed in real time
  • allow all strerr to be processed in real time
  • allow prompts for input to be processed (for credentials)
  • use debug logging to verify operation
  • support Windows/macOS/Unix

I think that the above features for cmd can be implemented in a smaller and more obvious way given all that has been learned with the current implementation.

(I wish you would setup a mailing list for GItPython to allow discussions)