summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/reindent.py
diff options
context:
space:
mode:
authorMariatta <Mariatta@users.noreply.github.com>2017-04-20 05:59:20 (GMT)
committerGitHub <noreply@github.com>2017-04-20 05:59:20 (GMT)
commit58f3c9dc8f5626abe09ac9738c34f6ba99ce2972 (patch)
tree290697b9a9bedc1bd5bcf14334a7798d716d09df /Tools/scripts/reindent.py
parent6dbdedb0b18a5ca850ab8ce512fda24d5a9d0688 (diff)
downloadcpython-58f3c9dc8f5626abe09ac9738c34f6ba99ce2972.zip
cpython-58f3c9dc8f5626abe09ac9738c34f6ba99ce2972.tar.gz
cpython-58f3c9dc8f5626abe09ac9738c34f6ba99ce2972.tar.bz2
bpo-30109: Fix reindent.py (GH-1207)
Skip the file if it has bad encoding.
Diffstat (limited to 'Tools/scripts/reindent.py')
-rwxr-xr-xTools/scripts/reindent.py6
1 files changed, 5 insertions, 1 deletions
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 @@ def check(file):
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)