summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2012-10-26 11:39:46 -0700
committerDan Smith <danms@us.ibm.com>2012-10-26 11:39:46 -0700
commit88f252a3d4209c7912f6ff36a6f703ef38f2546b (patch)
treefa56ed1f311d781ee59d4b2c67f972558b90683d
parent50a0f3efb6cc4ae9c94439eea346828d35080d6c (diff)
Fix hacking.py naivete regarding lines that look like imports
Right now, any line that starts with "from" (after whitespace removal) is considered an import line. That assumption leads to some unsavory parsing and crashing if the line doesn't match the expected format. This patch checks to make sure that the word "import" is in the line as well as starting with "from", which at least gets us a bit closer to a reasonable assumption. Fixes bug 1071849 Change-Id: Iab666fcd04a9aaa3a490737a173ee3189b9b8329
-rwxr-xr-xtools/hacking.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/hacking.py b/tools/hacking.py
index 1c2e11218..4e42d3e89 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -105,7 +105,7 @@ def import_normalize(line):
# convert "from x import y" to "import x.y"
# handle "from x import y as z" to "import x.y as z"
split_line = line.split()
- if (line.startswith("from ") and "," not in line and
+ if ("import" in line and line.startswith("from ") and "," not in line and
split_line[2] == "import" and split_line[3] != "*" and
split_line[1] != "__future__" and
(len(split_line) == 4 or