Repository: pre-commit/pre-commit-hooks

Issue:
detect-private-key hook appears to crash with images in the directory
Just added some images and a resources.qrc file to my PyQt4 project and got this error out of it. Is it because it tries to decode images as text?

```
Detect Private Key.......................................................Failed
hookid: detect-private-key

Traceback (most recent call last):

  File "C:\cygwin64\home\builder\.pre-commit\repo7jrxo4\py_env-default\Scripts\detect-private-key-script.py", line 9, in \<module\>

    load_entry_point('pre-commit-hooks==0.4.2', 'console_scripts', 'detect-private-key')()

  File "C:\cygwin64\home\builder\.pre-commit\repo7jrxo4\py_env-default\lib\site-packages\pre_commit_hooks\detect_private_key.py", line 17, in detect_private_key

    content = f.read()

  File "C:\cygwin64\home\builder\.pre-commit\repo7jrxo4\py_env-default\lib\encodings\cp1252.py", line 23, in decode

    return codecs.charmap_decode(input,self.errors,decoding_table)[0]

UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 44: character maps to \<undefined\>
```

Discussion:

Patch:
diff --git a/pre_commit_hooks/detect_private_key.py b/pre_commit_hooks/detect_private_key.py
index 215ad56..782b680 100644
--- a/pre_commit_hooks/detect_private_key.py
+++ b/pre_commit_hooks/detect_private_key.py
@@ -1,7 +1,6 @@
 from __future__ import print_function
 
 import argparse
-import io
 import sys
 
 
@@ -13,12 +12,11 @@ def detect_private_key(argv=None):
     private_key_files = []
 
     for filename in args.filenames:
-        with io.open(filename, 'r') as f:
-            content = f.read()
-            if 'BEGIN RSA PRIVATE KEY' in content:
-                private_key_files.append(content)
-            if 'BEGIN DSA PRIVATE KEY' in content:
-                private_key_files.append(content)
+        content = open(filename, 'rb').read()
+        if b'BEGIN RSA PRIVATE KEY' in content:
+            private_key_files.append(content)
+        if b'BEGIN DSA PRIVATE KEY' in content:
+            private_key_files.append(content)
 
     if private_key_files:
         for private_key_file in private_key_files:


Test patch:
diff --git a/tests/detect_private_key_test.py b/tests/detect_private_key_test.py
index 6d2e627..c912624 100644
--- a/tests/detect_private_key_test.py
+++ b/tests/detect_private_key_test.py
@@ -10,6 +10,8 @@ TESTS = (
     (b'-----BEGIN DSA PRIVATE KEY-----', 1),
     (b'ssh-rsa DATA', 0),
     (b'ssh-dsa DATA', 0),
+    # Some arbitrary binary data
+    (b'\xa2\xf1\x93\x12', 0),
 )