peritus / bumpversion

Version-bump your software with a single command
https://pypi.python.org/pypi/bumpversion
MIT License
1.5k stars 148 forks source link

TypeError: environment can only contain strings #135

Open wooyek opened 8 years ago

wooyek commented 8 years ago

The commit command after is failing on windows and PY3. Can anybody help with this?

Traceback (most recent call last):
  File "c:\Python35\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\Python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\projekty\github\django-pascal-templates\.pve\Scripts\bumpversion.exe\__main__.py", line 9, in <module>
  File "d:\projekty\github\django-pascal-templates\.pve\lib\site-packages\bumpversion\__init__.py", line 994, in main
    vcs.commit(message=commit_message)
  File "d:\projekty\github\django-pascal-templates\.pve\lib\site-packages\bumpversion\__init__.py", line 73, in commit
    list(os.environ.items()) + [(b'HGENCODING', b'utf-8')]
  File "c:\Python35\lib\subprocess.py", line 629, in check_output
    **kwargs).stdout
  File "c:\Python35\lib\subprocess.py", line 696, in run
    with Popen(*popenargs, **kwargs) as process:
  File "c:\Python35\lib\subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "c:\Python35\lib\subprocess.py", line 1220, in _execute_child
    startupinfo)
TypeError: environment can only contain strings
smsearcy commented 8 years ago

I ran into the same issue and I think the problem is that the environment strings are being coded as bytes instead of strings.

I'm going to test that and create a pull request.

TAGC commented 7 years ago

Same problem, and I can confirm.

Running under Python 3.5.2

Using byte strings

>>> subprocess.check_output(["cmd"], env=dict(list(os.environ.items()) + [(b'HGENCODING', b'utf-8')]))
Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    subprocess.check_output(["cmd"], env=dict(list(os.environ.items()) + [(b'HGENCODING', b'utf-8')]))
  File "C:\Users\davidfallah\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "C:\Users\davidfallah\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 693, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\davidfallah\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\davidfallah\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
TypeError: environment can only contain strings

Using regular strings

>>> subprocess.check_output(["cmd"], env=dict(list(os.environ.items()) + [('HGENCODING', 'utf-8')]))
b'Microsoft Windows [Version 6.1.7601]\r\nCopyright (c) 2009 Microsoft Corporation.  All rights reserved.\r\n\r\nC:\\Users\\davidfallah\\AppData\\Local\\Programs\\Python\\Python35-32>'

Running under Python 2.7.10

Using byte strings

subprocess.check_output(["cmd"], env=dict(list(os.environ.items()) + [(b'HGENCODING', b'utf-8')]))
'Microsoft Windows [Version 6.1.7601]\r\nCopyright (c) 2009 Microsoft Corporation.  All rights reserved.\r\n\r\nC:\\Python27>'

Using regular strings

>>> subprocess.check_output(["cmd"], env=dict(list(os.environ.items()) + [('HGENCODING', 'utf-8')]))
'Microsoft Windows [Version 6.1.7601]\r\nCopyright (c) 2009 Microsoft Corporation.  All rights reserved.\r\n\r\nC:\\Python27>'
kvamshk commented 7 years ago

is there any resolution/work around please?

vcorreze commented 6 years ago

Same issue here. Is there any news ?

wooyek commented 6 years ago

Try https://github.com/c4urself/bump2version