diff options
author | cpopa <devnull@localhost> | 2014-06-15 09:25:53 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2014-06-15 09:25:53 +0300 |
commit | e7ee2c6c0930701ed6efa7efa9f14ff7764c3de1 (patch) | |
tree | 90cac70720a87dd437358917393410b32a64cf3c | |
parent | 2f173114dfd45952daa34f2eb5912e8914d8fdb7 (diff) | |
download | pylint-e7ee2c6c0930701ed6efa7efa9f14ff7764c3de1.tar.gz |
Fix a potential crash for accessors like "{0.missing}".
-rw-r--r-- | checkers/strings.py | 2 | ||||
-rw-r--r-- | test/input/func_string_format_py27.py | 1 | ||||
-rw-r--r-- | test/messages/func_string_format_py27.txt | 3 |
3 files changed, 4 insertions, 2 deletions
diff --git a/checkers/strings.py b/checkers/strings.py index 4f4293a..9be6627 100644 --- a/checkers/strings.py +++ b/checkers/strings.py @@ -188,7 +188,7 @@ def get_access_path(key, parts): path.append(".{}".format(specifier)) else: path.append("[{!r}]".format(specifier)) - return key + "".join(path) + return str(key) + "".join(path) class StringFormatChecker(BaseChecker): diff --git a/test/input/func_string_format_py27.py b/test/input/func_string_format_py27.py index cd3071b..a492bb2 100644 --- a/test/input/func_string_format_py27.py +++ b/test/input/func_string_format_py27.py @@ -68,3 +68,4 @@ def pprint(): print "{a}".format(a=Missing())
print log("{}".format(2, "info"))
print "{pid}".format(pid=os.getpid())
+ print "{0.missing}".format(2)
diff --git a/test/messages/func_string_format_py27.txt b/test/messages/func_string_format_py27.txt index 632ff60..53edb8b 100644 --- a/test/messages/func_string_format_py27.txt +++ b/test/messages/func_string_format_py27.txt @@ -20,4 +20,5 @@ W: 61:pprint: Using invalid lookup key 400 in format specifier 'a.ids[3][400]' W: 62:pprint: Using invalid lookup key "'string'" in format specifier 'a.ids[3]["\'string\'"]'
W: 66:pprint: Missing keyword argument 'b' for format string
W: 66:pprint: Unused format argument 'a'
-W: 67:pprint: Using invalid lookup key 0 in format specifier 'a[0]'
\ No newline at end of file +W: 67:pprint: Using invalid lookup key 0 in format specifier 'a[0]'
+W: 71:pprint: Missing format attribute 'missing' in format specifier '0.missing'
\ No newline at end of file |