Skip to content
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

Git commit fails on Windows 7/8.1 with TypeError: environment can only contain strings #67

Closed
russgray opened this issue Jan 9, 2015 · 5 comments

Comments

@russgray
Copy link

russgray commented Jan 9, 2015

I'm trying to use bumpversion on Windows, but I get an error when I try to autocommit with git. I believe the problem is in BaseVCS.commit with the following code:

subprocess.check_output(cls._COMMIT_COMMAND + [f.name], env=dict(
    list(os.environ.items()) + [('HGENCODING', 'utf-8')]
))

Dumping env from within subprocess.py gives the following output:

{

...

 'FRAMEWORKVERSION': 'v4.0.30319',
 'FRAMEWORKVERSION32': 'v4.0.30319',
 'FSHARPINSTALLDIR': 'C:\\Program Files (x86)\\Microsoft SDKs\\F#\\3.1\\Framework\\v4.0\\',
 u'HGENCODING': u'utf-8',
 'HOME': 'C:\\Users\\rgray',
 'HOMEPATH': '\\',

...

}

Note that HGENCODING seems to have been added to the dict as unicode. If I force it to ascii as follows then it works as expected:

subprocess.check_output(cls._COMMIT_COMMAND + [f.name], env=dict(
    list(os.environ.items()) + [('HGENCODING'.encode('ascii'), 'utf-8'.encode('ascii'))]
))

I will submit a pull request with this fix.

The stack trace:

Traceback (most recent call last):
  File "C:\Python27\Scripts\bumpversion-script.py", line 9, in <module>
    load_entry_point('bumpversion==0.5.0', 'console_scripts', 'bumpversion')()
  File "C:\Python27\lib\site-packages\bumpversion\__init__.py", line 965, in main
    vcs.commit(message=commit_message)
  File "C:\Python27\lib\site-packages\bumpversion\__init__.py", line 74, in commit
    list(os.environ.items()) + [('HGENCODING', 'utf-8')]
  File "C:\Python27\lib\subprocess.py", line 537, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 679, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
    startupinfo)
TypeError: environment can only contain strings
@peritus
Copy link
Owner

peritus commented Jan 15, 2015

Fixed (for details see #64).

@peritus peritus closed this as completed Jan 15, 2015
@Nurdok
Copy link

Nurdok commented Sep 29, 2016

Seems like #64 wasn't actually merged and this also happens on Windows 10. Are there plans to implement Windows support soon?

@wooyek
Copy link

wooyek commented Apr 13, 2017

In my case on Windows 10 in Py 3.5 making additional env setting HGENCODING, a string worked around this issue:

    @classmethod
    def commit(cls, message):
        f = NamedTemporaryFile('wb', delete=False)
        f.write(message.encode('utf-8'))
        f.close()
        subprocess.check_output(cls._COMMIT_COMMAND + [f.name], env=dict(
            list(os.environ.items()) + [('HGENCODING', 'utf-8')]
        ))
        os.unlink(f.name)

@DancingQuanta
Copy link

I am still having issues when using Anaconda and cygwin with latest bumpversion.

@wooyek
Copy link

wooyek commented Mar 8, 2018

This project is stalled. Try to use bump2version instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants