# HG changeset patch # User Ludovic Chabant # Date 1456471596 28800 # Node ID a920b2ab1f316d675fd2802ecdc9769979ac44bd # Parent c1a94e1beb9d2e88607867a6d9b330cec1df473a admin: Fix OS-specific new line problems when editing pages. diff -r c1a94e1beb9d -r a920b2ab1f31 foodtruck/views/edit.py --- a/foodtruck/views/edit.py Thu Feb 25 22:30:16 2016 -0800 +++ b/foodtruck/views/edit.py Thu Feb 25 23:26:36 2016 -0800 @@ -33,7 +33,7 @@ if 'do_preview' in request.form or 'do_save' in request.form or \ 'do_save_and_commit' in request.form: logger.debug("Writing page: %s" % page.path) - with open(page.path, 'w', encoding='utf8') as fp: + with open(page.path, 'w', encoding='utf8', newline='') as fp: fp.write(page_text) flash("%s was saved." % os.path.relpath( page.path, site_app.root_dir)) @@ -66,7 +66,7 @@ data = {} data['is_new_page'] = False data['url_cancel'] = url_for('list_source', source_name=page.source.name) - with open(page.path, 'r', encoding='utf8') as fp: + with open(page.path, 'r', encoding='utf8', newline='') as fp: data['page_text'] = fp.read() data['is_dos_nl'] = "1" if '\r\n' in data['page_text'] else "0"