Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions runestone/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def init():
paver_final = paver_stuff.decode('utf-8') % conf_dict
config_final = config_stuff.decode('utf-8') % conf_dict

# On Windows, Python 3.6, the bytes read from ``template_base_dir`` and ``config_stuff`` contain Windows-style ``\n\r``. Unfortunately, `resource_string <http://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access>`_ does no universal newline support, so these remain intact. When written out, this is changed to ``\n\n``, making the file double-spaced. Python 3's `StringIO <https://docs.python.org/3/library/io.html#io.StringIO>`_ class provides universal newline support, while Python 2's `StringIO <https://docs.python.org/2/library/stringio.html#StringIO.StringIO>`__ doesn't.
if six.PY3:
# Per the `TextIOWrapper docs <https://docs.python.org/3/library/io.html#io.TextIOWrapper>`_, ``newline=None`` selects universal newline mode. The Python 3 StringIO_ class's ``newline`` argument works the same.
paver_final = six.StringIO(paver_final, newline=None).read()
config_final = six.StringIO(config_final, newline=None).read()

with open('pavement.py','w') as pvf:
pvf.write(paver_final)

Expand Down