Gitcc not compatible with python 3.4 ?
spyropoulosl opened this issue · 3 comments
While running gitcc rebase I get the below. When used python 2.7 all worked fine. As I didn't find somewhere that the project is python 2 specific I open this ticket. Let me know if it's not suppose to work on python 3.
> git add .gitcc
> git branch -f master_cc
Traceback (most recent call last):
File "x:\usr\git-cc-master\rebase.py", line 66, in doCommit
commit(cs)
File "x:\usr\git-cc-master\rebase.py", line 149, in commit
cs.commit()
File "x:\usr\git-cc-master\rebase.py", line 195, in commit
git_exec(['commit', '-m', comment.encode(ENCODING)], env=env)
File "x:\usr\git-cc-master\common.py", line 47, in git_exec
return popen('git', cmd, GIT_DIR, encoding='UTF-8', **args)
File "x:\usr\git-cc-master\common.py", line 56, in popen
debug('> ' + ' '.join(map(f, cmd)))
File "x:\usr\git-cc-master\common.py", line 55, in <lambda>
f = lambda a: a if not a.count(' ') else '"%s"' % a
TypeError: Type str doesn't support the buffer API
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "x:\usr\git-cc-master\gitcc", line 48, in <module>
main()
File "x:\usr\git-cc-master\gitcc", line 14, in main
return invoke(cmd, args)
File "x:\usr\git-cc-master\gitcc", line 38, in invoke
cmd.main(*args)
File "x:\usr\git-cc-master\rebase.py", line 55, in main
doStash(lambda: doCommit(cs), stash)
File "x:\usr\git-cc-master\common.py", line 38, in doStash
f()
File "x:\usr\git-cc-master\rebase.py", line 55, in <lambda>
doStash(lambda: doCommit(cs), stash)
File "x:\usr\git-cc-master\rebase.py", line 72, in doCommit
git_exec(['branch', '-f', CC_TAG])
File "x:\usr\git-cc-master\common.py", line 47, in git_exec
return popen('git', cmd, GIT_DIR, encoding='UTF-8', **args)
File "x:\usr\git-cc-master\common.py", line 62, in popen
raise Exception(decodeString(encoding, stderr + stdout))
Exception: fatal: Not a valid object name: 'master'.
I got the very same problem here, using Windows 7 and Python 3.5 and git-cc 01a35a3a
Traceback (most recent call last):
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\rebase.py", line 65, in doCommit
commit(cs)
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\rebase.py", line 148, in commit
cs.commit()
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\rebase.py", line 194, in commit
git_exec(['commit', '-m', comment.encode(ENCODING)], env=env)
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\common.py", line 77, in git_exec
return popen('git', cmd, GIT_DIR, encoding='UTF-8', **args)
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\common.py", line 86, in popen
debug('> ' + ' '.join(map(f, cmd)))
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\common.py", line 85, in <lambda>
f = lambda a: a if not a.count(' ') else '"%s"' % a
TypeError: a bytes-like object is required, not 'str'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35-32\Scripts\gitcc-script.py", line 9, in <module>
load_entry_point('git-cc==1.0.1.dev0', 'console_scripts', 'gitcc')()
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\gitcc.py", line 25, in main
return invoke(cmd, args)
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\gitcc.py", line 50, in invoke
cmd.main(*args)
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\rebase.py", line 54, in main
doStash(lambda: doCommit(cs), stash)
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\common.py", line 68, in doStash
f()
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\rebase.py", line 54, in <lambda>
doStash(lambda: doCommit(cs), stash)
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\rebase.py", line 71, in doCommit
git_exec(['branch', '-f', CC_TAG])
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\common.py", line 77, in git_exec
return popen('git', cmd, GIT_DIR, encoding='UTF-8', **args)
File "c:\program files (x86)\python35-32\lib\site-packages\git_cc\common.py", line 92, in popen
raise Exception(decodeString(encoding, stderr + stdout))
Exception: fatal: Not a valid object name: 'master'.
I suppose we suffer from a text-versus-binary-data issue; the argument should be a string but somehow it is "only" a byte array.
https://docs.python.org/3/howto/pyporting.html#text-versus-binary-data
Apparently, the problem is the call to encode
in rebase.py:194
git_exec(['commit', '-m', comment.encode(ENCODING)], env=env)
In python3 this method of str
returns an instance of bytes
. Simply removing this call solved the issue here. However, I don't know the code too well to judge the consequences. Can this break non-ascii commit messages?
git_exec(['commit', '-m', comment], env=env)
I've tried (badly) to make git-cc compatible with both 2.x and 3.x. I'm afraid my python knowledge was never very good. If removing the encoding works I'm happy to take it out. Another suggestion is to "decode" the bytes for the debugging in common.py which is where the current error seems to be.
I should mention/warn you that I haven't used git-cc in years so I can't really test it. Sorry I can't be more help. :(