-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BF: convert revision to str for call #52
Conversation
Avoid error converting str / bytes in subprocess.call
@@ -74,7 +74,8 @@ def try_rebase(remote, branch): | |||
(rev, ignore) = p.communicate() | |||
if p.wait() != 0: | |||
return True | |||
cmd = ['git', 'update-ref', 'refs/heads/%s' % branch, rev.strip()] | |||
rev = rev.strip().decode('ascii') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why you didn't just call dec(rev.strip())
with the dec
function defined earlier? That works for me. AFAICT L77 should just be:
cmd = ['git', 'update-ref', 'refs/heads/%s' % branch, dec(rev.strip())]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm right in saying that rev
should always be a commit hash, so ascii
or utf-8
decoding (via dec
) should give the same result. I guess the only advantage of ascii
is that it will give an error when the result is other than a hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes mkdocs#722. See also c-w/ghp-import#52
This appears to be a duplicate of #42. |
Avoid error converting str / bytes in subprocess.call
Without this change, on Windows and Python 3.5, I get this from
ghp-import _build/html
:(py35) C:\repos\la-eeg-uci [master]> ghp-import.exe ._build\html
Traceback (most recent call last):
File "C:\tmp\py35\Scripts\ghp-import-script.py", line 9, in
load_entry_point('ghp-import==0.4.2', 'console_scripts', 'ghp-import')()
File "c:\repos\ghp-import\ghp_import.py", line 194, in main
if not try_rebase(opts.remote, opts.branch):
File "c:\repos\ghp-import\ghp_import.py", line 78, in try_rebase
if sp.call(cmd) != 0:
File "C:\Python35\lib\subprocess.py", line 560, in call
with Popen(_popenargs, *_kwargs) as p:
File "C:\Python35\lib\subprocess.py", line 950, in init
restore_signals, start_new_session)
File "C:\Python35\lib\subprocess.py", line 1194, in _execute_child
args = list2cmdline(args)
File "C:\Python35\lib\subprocess.py", line 754, in list2cmdline
needquote = (" " in arg) or ("\t" in arg) or not arg
TypeError: a bytes-like object is required, not 'str'