Worked around a Python 2.6 bug whereby file streams don't respect encoding #262

wants to merge 1 commit into


None yet

2 participants

fgimian commented Jul 23, 2015

Hello again 😄

After many hours of trying to find the best way to solve this problem, here's my solution. It ensures that Python 2.6 file streams will always encode to bytes before writing to the output stream. This works around Python issue 4947.

You may reproduce the original problem as follows with Python 2.6:

# encoding: utf-8
from invoke import task, run

def output_strange_stuff():
    print '└──'

def breakit():
    run('invoke output_strange_stuff', encoding='utf-8')

Then run:

invoke breakit

Feel free to ask any questions and thanks for the amazing tool! 😄


fgimian commented Jul 28, 2015

Oh dear, I broken Python 3.x compatibility. I'll look into a better way, bear with me. 😄

@fgimian fgimian Worked around a Python 2.6 bug whereby file streams don't respect enc…
@bitprophet bitprophet referenced this pull request May 26, 2016

Catchall 'encoding needs to get un-crap-ified' ticket #350

10 of 11 tasks complete

This should be obviated by changes in #350 now. Please comment after the 0.13 release comes out if that doesn't fix things for you. Thanks!

@bitprophet bitprophet closed this Jun 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment