Modernize use of range()

In Python 3, range() behaves like the old xrange().
The difference between range() and xrange() is usually not significant,
especially if the whole result is iterated over.

Convert xrange() usage to range() for small ranges.
Use modern idioms in a few other uses of range().

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Petr Viktorin
2015-09-01 11:42:01 +02:00
committed by Jan Cholasta
parent 9e917cae39
commit 5178e9a597
22 changed files with 45 additions and 46 deletions
+3 -3
View File
@@ -1475,12 +1475,12 @@ class IA5Str(Str):
def _convert_scalar(self, value, index=None):
if isinstance(value, six.string_types):
for i in xrange(len(value)):
if ord(value[i]) > 127:
for char in value:
if ord(char) > 127:
raise ConversionError(name=self.get_param_name(),
index=index,
error=_('The character %(char)r is not allowed.') %
dict(char=value[i],)
dict(char=char,)
)
return super(IA5Str, self)._convert_scalar(value, index)