[3.6] bpo-30109: Fix reindent.py (GH-1207) (GH-1208)

Skip the file if it has bad encoding.
(cherry picked from commit 58f3c9dc8f5626abe09ac9738c34f6ba99ce2972)
diff --git a/Tools/scripts/reindent.py b/Tools/scripts/reindent.py
index 18424de..f6dadaa 100755
--- a/Tools/scripts/reindent.py
+++ b/Tools/scripts/reindent.py
@@ -118,7 +118,11 @@
     if verbose:
         print("checking", file, "...", end=' ')
     with open(file, 'rb') as f:
-        encoding, _ = tokenize.detect_encoding(f.readline)
+        try:
+            encoding, _ = tokenize.detect_encoding(f.readline)
+        except SyntaxError as se:
+            errprint("%s: SyntaxError: %s" % (file, str(se)))
+            return
     try:
         with open(file, encoding=encoding) as f:
             r = Reindenter(f)