Skip to content

Commit

Permalink
write to stdout correctly on python 3
Browse files Browse the repository at this point in the history
fixes #20.

sys.stdout is already a unicode interface in python 3 and
codecs.getwriter doesn't know this.

IPython has a load of py2/3 compat code so let's use that.
  • Loading branch information
aaren committed Apr 22, 2015
1 parent 4788db0 commit 409c355
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions notedown/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import argparse
import pkg_resources
import io
import codecs

import IPython.nbformat as nbformat
from IPython.nbconvert.preprocessors.execute import ExecutePreprocessor
from IPython.utils.io import unicode_std_stream

from .notedown import (MarkdownReader,
MarkdownWriter,
Expand Down Expand Up @@ -262,7 +262,7 @@ def cli():

elif args.output == '-':
# write stdout
writer.write(notebook, codecs.getwriter('utf-8')(sys.stdout))
writer.write(notebook, unicode_std_stream('stdout'))

elif args.output != '-':
# write to filename
Expand Down

0 comments on commit 409c355

Please sign in to comment.