Skip to content

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

Closed
fgimian wants to merge 1 commit intopyinvoke:masterfrom
fgimian:python-2.6-encoding-bug
Closed

Worked around a Python 2.6 bug whereby file streams don't respect encoding#262
fgimian wants to merge 1 commit intopyinvoke:masterfrom
fgimian:python-2.6-encoding-bug

Conversation

@fgimian
Copy link
Copy Markdown

@fgimian 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

@task
def output_strange_stuff():
    print '└──'

@task
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! 😄

Cheers
Fotis

@fgimian
Copy link
Copy Markdown
Author

fgimian commented Jul 28, 2015

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

@bitprophet
Copy link
Copy Markdown
Member

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants