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__)))