summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRene Zhang <rz99@cornell.edu>2015-08-20 18:01:44 -0700
committerRene Zhang <rz99@cornell.edu>2015-08-20 18:01:44 -0700
commit69f806375f8d7a3f17722e8140f30b2e354d9aa6 (patch)
tree6e2b1e5c14475cd0c23cadd199a73a1f146f3a69
parent7a37a32a84a322d8c64b8ecd508e0dd9f34b995c (diff)
downloadpylint-69f806375f8d7a3f17722e8140f30b2e354d9aa6.tar.gz
Fix inference error on string format
-rw-r--r--pylint/checkers/strings.py2
-rw-r--r--pylint/test/functional/string_formatting_failed_inference.py4
2 files changed, 6 insertions, 0 deletions
diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py
index 528aa5d..cfa1a01 100644
--- a/pylint/checkers/strings.py
+++ b/pylint/checkers/strings.py
@@ -494,6 +494,8 @@ class StringMethodsChecker(BaseChecker):
previous = previous.getitem(specifier)
except (IndexError, TypeError):
warn_error = True
+ except astroid.InferenceError:
+ break
else:
try:
# Lookup __getitem__ in the current node,
diff --git a/pylint/test/functional/string_formatting_failed_inference.py b/pylint/test/functional/string_formatting_failed_inference.py
new file mode 100644
index 0000000..aa8d24a
--- /dev/null
+++ b/pylint/test/functional/string_formatting_failed_inference.py
@@ -0,0 +1,4 @@
+""" Testing string format with a failed inference. This should not crash. """
+
+import collections
+"{dict[0]}".format(dict=collections.defaultdict(int))