From 780510dc326f811209d0f80ca8e16f025af170f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonel=20C=C3=A2mara?= Date: Sat, 15 Jul 2017 09:52:58 +0100 Subject: [PATCH] Fixes #1684 --- gluon/fileutils.py | 4 ++-- gluon/tests/test_fileutils.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gluon/fileutils.py b/gluon/fileutils.py index 27fe8a8d..0fa29acf 100644 --- a/gluon/fileutils.py +++ b/gluon/fileutils.py @@ -415,10 +415,10 @@ def fix_newlines(path): |\r| )''') for filename in listdir(path, '.*\.(py|html)$', drop=False): - rdata = read_file(filename, 'rb') + rdata = read_file(filename, 'r') wdata = regex.sub('\n', rdata) if wdata != rdata: - write_file(filename, wdata, 'wb') + write_file(filename, wdata, 'w') def copystream( diff --git a/gluon/tests/test_fileutils.py b/gluon/tests/test_fileutils.py index 5e408796..a09f5704 100644 --- a/gluon/tests/test_fileutils.py +++ b/gluon/tests/test_fileutils.py @@ -1,10 +1,11 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import os import unittest import datetime -from gluon.fileutils import parse_version +from gluon.fileutils import parse_version, fix_newlines, listdir class TestFileUtils(unittest.TestCase): @@ -22,3 +23,6 @@ class TestFileUtils(unittest.TestCase): # Semantic Beta rtn = parse_version('Version 2.14.1-beta+timestamp.2016.03.21.22.35.26') self.assertEqual(rtn, (2, 14, 1, 'beta', datetime.datetime(2016, 3, 21, 22, 35, 26))) + + def test_fix_newlines(self): + fix_newlines(os.path.dirname(os.path.abspath(__file__)))