diff --git a/git_cl.py b/git_cl.py index 87904a900..fc77ef8c2 100755 --- a/git_cl.py +++ b/git_cl.py @@ -666,13 +666,12 @@ def _GetYapfIgnorePatterns(top_dir): if not os.path.exists(yapfignore_file): return ignore_patterns - with open(yapfignore_file) as f: - for line in f.readlines(): - stripped_line = line.strip() - # Comments and blank lines should be ignored. - if stripped_line.startswith('#') or stripped_line == '': - continue - ignore_patterns.add(stripped_line) + for line in gclient_utils.FileRead(yapfignore_file).split('\n'): + stripped_line = line.strip() + # Comments and blank lines should be ignored. + if stripped_line.startswith('#') or stripped_line == '': + continue + ignore_patterns.add(stripped_line) return ignore_patterns diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 623bdccf2..e93fecc5a 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -3947,8 +3947,8 @@ class CMDFormatTestCase(unittest.TestCase): super(CMDFormatTestCase, self).tearDown() def _make_temp_file(self, fname, contents): - with open(os.path.join(self._top_dir, fname), 'w') as tf: - tf.write('\n'.join(contents)) + gclient_utils.FileWrite(os.path.join(self._top_dir, fname), + ('\n'.join(contents))) def _make_yapfignore(self, contents): self._make_temp_file('.yapfignore', contents) @@ -4063,6 +4063,18 @@ class CMDFormatTestCase(unittest.TestCase): ] self._check_yapf_filtering(files, expected) + def testYapfHandleUtf8(self): + self._make_yapfignore(['test.py', 'test_🌐.py']) + files = [ + 'test.py', + 'test_🌐.py', + 'test2.py', + ] + expected = [ + 'test2.py', + ] + self._check_yapf_filtering(files, expected) + def testYapfignoreBlankLines(self): self._make_yapfignore(['test.py', '', '', 'test2.py']) files = [