From 88f252a3d4209c7912f6ff36a6f703ef38f2546b Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 26 Oct 2012 11:39:46 -0700 Subject: 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 --- tools/hacking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit