guyzmo / git-repo

Git-Repo: CLI utility to manage git services from your workspace
https://webchat.freenode.net/?channels=#git-repo
Other
842 stars 86 forks source link

extract_config: AttributeError: 'write' object has no attribute 'update' on Python 2 #177

Closed jayvdb closed 6 years ago

jayvdb commented 7 years ago
$ python -m git_repo.extract_config
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/jayvdb/projects/git/git-repo/git_repo/extract_config.py", line 33, in <module>
    gconf_new=os.path.expanduser(len(sys.argv) >= 2 and sys.argv[1] or '~/.gitconfig-repos')
  File "/home/jayvdb/projects/git/git-repo/git_repo/extract_config.py", line 19, in extract_gitrepo_conf
    cnew.update({s: {k:v for k,v in cold.items(s)} for s in sections})
AttributeError: 'write' object has no attribute 'update'

Turns out, I was implicitly using python2 when running python -m git_repo.extract_config , and the git.config is quite different on Python 2. My GitPython on python2 is 2.1.7, whereas on python3 it is 2.1.3. I've also tested GitPython master on python3, and it also works. So I believe it is just an oddity with Python 2. Anyway, git-repo isnt supposed to work on python2, but the command given in the README.md bypasses the sanity check in setup.py

guyzmo commented 7 years ago

Good note! I use python3 as main python, which led to this mistake. Thanks for the PR!