summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpopa <devnull@localhost>2014-06-08 10:16:06 +0300
committercpopa <devnull@localhost>2014-06-08 10:16:06 +0300
commitcd4fc378a3313a16e175e482ae71864cffd17f00 (patch)
tree967f661b35a0c67ebf75ee9950e4414dd77b0f8c
parent96119dbbbcdab4e46ccfde4ed57cca20ee34a86b (diff)
downloadpylint-cd4fc378a3313a16e175e482ae71864cffd17f00.tar.gz
Make sure that split_format_field_names always returns ints instead of longs for Python 2.
-rw-r--r--checkers/strings.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/checkers/strings.py b/checkers/strings.py
index 6859ef5..4f6ff1d 100644
--- a/checkers/strings.py
+++ b/checkers/strings.py
@@ -117,8 +117,18 @@ if _PY3K:
def split_format_field_names(format_string):
return _string.formatter_field_name_split(format_string)
else:
+ def _field_iterator_convertor(iterator):
+ for is_attr, key in iterator:
+ if not isinstance(key, str):
+ yield is_attr, int(key)
+ else:
+ yield is_attr, key
+
def split_format_field_names(format_string):
- return format_string._formatter_field_name_split()
+ keyname, fielditerator = format_string._formatter_field_name_split()
+ # it will return longs, instead of ints, which will complicate
+ # the output
+ return keyname, _field_iterator_convertor(fielditerator)
def parse_format_method_string(format_string):
"""