Skip to content

Commit b88441f

Browse files
committed
Convert '{}'.format() to '{0}'.format() for Python 2.6 compatibility
1 parent a4a0fbc commit b88441f

6 files changed

Lines changed: 14 additions & 13 deletions

File tree

future/builtins/backports/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def g(a, b=None):
136136
def decorator(function):
137137
@functools.wraps(function)
138138
def wrapper(*args, **kwargs):
139-
errmsg = "argument can't be {}"
139+
errmsg = "argument can't be {0}"
140140
for (argnum, mytype) in zip(argnums, disallowed_types):
141141
# Only restrict kw args only if they are passed:
142142
if len(args) <= argnum:

future/builtins/backports/newbytes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __repr__(self):
7979
return 'b' + super(newbytes, self).__repr__()
8080

8181
def __str__(self):
82-
return 'b' + "'{}'".format(super(newbytes, self).__str__())
82+
return 'b' + "'{0}'".format(super(newbytes, self).__str__())
8383

8484
def __getitem__(self, y):
8585
value = super(newbytes, self).__getitem__(y)
@@ -117,7 +117,7 @@ def __rmul__(self, other):
117117
return newbytes(super(newbytes, self).__rmul__(other))
118118

119119
def join(self, iterable_of_bytes):
120-
errmsg = 'sequence item {}: expected bytes, {} found'
120+
errmsg = 'sequence item {0}: expected bytes, {1} found'
121121
if isbytes(iterable_of_bytes) or istext(iterable_of_bytes):
122122
raise TypeError(errmsg.format(0, type(iterable_of_bytes)))
123123
for i, item in enumerate(iterable_of_bytes):
@@ -230,7 +230,7 @@ def __ne__(self, other):
230230
else:
231231
return True
232232

233-
unorderable_err = 'unorderable types: bytes() and {}'
233+
unorderable_err = 'unorderable types: bytes() and {0}'
234234

235235
def __lt__(self, other):
236236
if not isbytes(other):

future/builtins/backports/newint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __new__(cls, x=0, base=10):
4747
val = x
4848
else:
4949
if not isint(val):
50-
raise TypeError('__int__ returned non-int ({})'.format(type(val)))
50+
raise TypeError('__int__ returned non-int ({0})'.format(type(val)))
5151

5252
if base != 10:
5353
# Explicit base
@@ -69,7 +69,7 @@ def __new__(cls, x=0, base=10):
6969
try:
7070
return super(newint, cls).__new__(cls, newbytes(val))
7171
except:
72-
raise TypeError("newint argument must be a string or a number, not '{}'".format(
72+
raise TypeError("newint argument must be a string or a number, not '{0}'".format(
7373
type(val)))
7474

7575

future/builtins/backports/newstr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class newstr(unicode):
5555
"""
5656
A backport of the Python 3 str object to Py2
5757
"""
58-
no_convert_msg = "Can't convert '{}' object to str implicitly"
58+
no_convert_msg = "Can't convert '{0}' object to str implicitly"
5959

6060
def __new__(cls, *args, **kwargs):
6161
"""
@@ -101,7 +101,7 @@ def __getitem__(self, y):
101101
return newstr(super(newstr, self).__getitem__(y))
102102

103103
def __contains__(self, key):
104-
errmsg = "'in <string>' requires string as left operand, not {}"
104+
errmsg = "'in <string>' requires string as left operand, not {0}"
105105
if isinstance(key, newstr):
106106
newkey = key
107107
elif isinstance(key, unicode):
@@ -130,7 +130,7 @@ def __rmul__(self, other):
130130
return newstr(super(newstr, self).__rmul__(other))
131131

132132
def join(self, iterable):
133-
errmsg = 'sequence item {}: expected unicode string, found bytes'
133+
errmsg = 'sequence item {0}: expected unicode string, found bytes'
134134
for i, item in enumerate(iterable):
135135
if isinstance(item, bytes):
136136
raise TypeError(errmsg.format(i))
@@ -233,7 +233,7 @@ def __ne__(self, other):
233233
else:
234234
return True
235235

236-
unorderable_err = 'unorderable types: str() and {}'
236+
unorderable_err = 'unorderable types: str() and {0}'
237237

238238
def __lt__(self, other):
239239
if not istext(other):

future/standard_library/test/support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def _is_ipv6_enabled():
611611

612612
# Disambiguate TESTFN for parallel testing, while letting it remain a valid
613613
# module name.
614-
TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())
614+
TESTFN = "{0}_{1}_tmp".format(TESTFN, os.getpid())
615615

616616
# # FS_NONASCII: non-ASCII character encodable by os.fsencode(),
617617
# # or None if there is no such character.
@@ -1386,7 +1386,7 @@ def start(self):
13861386
try:
13871387
f = open(self.procfile, 'r')
13881388
except OSError as e:
1389-
warnings.warn('/proc not available for stats: {}'.format(e),
1389+
warnings.warn('/proc not available for stats: {0}'.format(e),
13901390
RuntimeWarning)
13911391
sys.stderr.flush()
13921392
return

future/tests/test_httpservers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
import tempfile
3131
from io import BytesIO
3232

33-
import unittest
3433
from test import support
34+
from future.tests.base import unittest
35+
3536
threading = support.import_module('threading')
3637

3738
TRAVIS_MSG = 'These tests sporadically fail on travis-ci for some reason. (Threading?)'

0 commit comments

Comments
 (0)