From dd9a07daf1b275612d25eeabc96538150a18d5aa Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 19 Jan 2015 16:43:10 -0800 Subject: [PATCH] Fix end-of-file-fixer on windows --- pre_commit_hooks/end_of_file_fixer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pre_commit_hooks/end_of_file_fixer.py b/pre_commit_hooks/end_of_file_fixer.py index 0698a89..3349d83 100644 --- a/pre_commit_hooks/end_of_file_fixer.py +++ b/pre_commit_hooks/end_of_file_fixer.py @@ -16,6 +16,8 @@ def fix_file(file_obj): last_character = file_obj.read(1) # last_character will be '' for an empty file if last_character != b'\n' and last_character != b'': + # Needs this seek for windows, otherwise IOError + file_obj.seek(0, os.SEEK_END) file_obj.write(b'\n') return 1