-
Notifications
You must be signed in to change notification settings - Fork 146
Description
When trying to invoke bumpversion using Windows on Python 3, it fails with this traceback:
C:\Users\jaraco\yg\pan [default tip]> bumpversion.pya minor
Traceback (most recent call last):
File "c:\python\scripts\bumpversion.pya", line 9, in <module>
load_entry_point('bumpversion==0.3.8', 'console_scripts', 'bumpversion')()
File "C:\Program Files\Python34\lib\site-packages\bumpversion-0.3.8-py3.4.egg\bumpversion\__init__.py", line 579, in main
File "C:\Program Files\Python34\lib\site-packages\bumpversion-0.3.8-py3.4.egg\bumpversion\__init__.py", line 163, in commit
File "C:\Program Files\Python34\lib\subprocess.py", line 605, in check_output
with Popen(*popenargs, stdout=PIPE, **kwargs) as process:
File "C:\Program Files\Python34\lib\subprocess.py", line 848, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python34\lib\subprocess.py", line 1078, in _execute_child
args = list2cmdline(args)
File "C:\Program Files\Python34\lib\subprocess.py", line 661, in list2cmdline
needquote = (" " in arg) or ("\t" in arg) or not arg
TypeError: Type str doesn't support the buffer API
This issue is due in part to the encoding of messages as bytes even though subprocess expects them to be strings.
Simply removing the encoding works around the TypeError and the program runs to completion, but the commit message has a "?" character in place of the "→". On further investigation, it appears the honoring of that character may be a bug with mercurial and not bumpversion or subprocess.
I'm able to run this simple script under Python 3 and it outputs the message properly:
# -*- coding: utf-8 -*-
import subprocess
msg = "A \u2192 B"
msg2 = "A → B"
assert msg == msg2
subprocess.call(["Powershell", "-C", "echo '" + msg + "'"])
Furthermore, I've confirmed that if I pass the msg to another Python 3 subprocess, the character in sys.argv is in fact unicode. If I pass the msg to a Python 2 subprocess, the character is lost and replaced by a '?'.
Overall, I believe the proper thing to do is remove the encoding of the string before passing to subprocess.
However, I suspect that will only work on Python 3 due to Python 1759845, so perhaps bumpversion should only do the encoding on Python 2.