diff options
author | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-02 12:23:21 -0700 |
---|---|---|
committer | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-02 12:23:21 -0700 |
commit | 8240d962ae0f09119fde7b1575924068f02c6d8c (patch) | |
tree | 5cfac0d391ac712df2b7400577d9c964c49bb53b /sqlparse | |
parent | e98b1922a10e8a5c2608d4cbe8cb9fa76c50baa5 (diff) | |
download | sqlparse-8240d962ae0f09119fde7b1575924068f02c6d8c.tar.gz |
Replace iter(range(len(...))) with enumerate
Diffstat (limited to 'sqlparse')
-rw-r--r-- | sqlparse/compat.py | 2 | ||||
-rw-r--r-- | sqlparse/lexer.py | 9 |
2 files changed, 4 insertions, 7 deletions
diff --git a/sqlparse/compat.py b/sqlparse/compat.py index 84d0c96..c1aacf6 100644 --- a/sqlparse/compat.py +++ b/sqlparse/compat.py @@ -18,7 +18,6 @@ if PY3: return str(s) - range = range text_type = str string_types = (str,) from io import StringIO @@ -33,7 +32,6 @@ elif PY2: return unicode(s, encoding) - range = xrange text_type = unicode string_types = (basestring,) from StringIO import StringIO diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index d2ae8f6..bb7fb48 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -16,7 +16,7 @@ import re from sqlparse import tokens from sqlparse.keywords import SQL_REGEX -from sqlparse.compat import StringIO, string_types, text_type, range +from sqlparse.compat import StringIO, string_types, text_type from sqlparse.utils import consume @@ -67,9 +67,8 @@ class Lexer(object): except UnicodeDecodeError: text = text.decode('unicode-escape') - iterable = iter(range(len(text))) - - for pos in iterable: + iterable = enumerate(text) + for pos, char in iterable: for rexmatch, action, new_state in statetokens: m = rexmatch(text, pos) @@ -93,7 +92,7 @@ class Lexer(object): consume(iterable, m.end() - pos - 1) break else: - yield tokens.Error, text[pos] + yield tokens.Error, char def tokenize(sql, encoding=None): |