10000 Change set literals with {...} to set([...]) for Py2.6 compatibility · thecodingchicken/python-future@275029a · GitHub
[go: up one dir, main page]

Skip to content

Commit 275029a

Browse files
author
Ed Schofield
committed
Change set literals with {...} to set([...]) for Py2.6 compatibility
1 parent 7fd42db commit 275029a

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

future/standard_library/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
6767
Notes
6868
-----
69-
This module only supports Python 2.7 and Python 3.1+.
69+
This module only supports Python 2.6 and Python 3.1+.
7070
7171
The following renames are already supported on Python 2.7 without any
7272
additional work from us::
@@ -82,6 +82,7 @@
8282
sys.maxint -> sys.maxsize # but this isn't identical
8383
8484
TODO: Check out these:
85+
Not available on Py2.6:
8586
unittest2 -> unittest?
8687
buffer -> memoryview?
8788
@@ -172,8 +173,8 @@
172173
'future.standard_library._markupbase': '_markupbase',
173174
}
174175

175-
REPLACED_MODULES = {'test', 'urllib', 'pickle'} # add dbm when we support it
176-
# These are entirely new to Python 2.7, so they cause no potential clashes
176+
REPLACED_MODULES = set(['test', 'urllib', 'pickle']) # add dbm when we support it
177+
# These are entirely new to Python 2.x, so they cause no potential clashes
177178
# xmlrpc, tkinter, http, html
178179

179180

@@ -209,11 +210,11 @@ def __init__(self, old_to_new):
209210
# print(both)
210211
assert len(both) == 0, \
211212
'Ambiguity in renaming (handler not implemented'
212-
self.new_to_old = {new: old for (old, new) in old_to_new.items()}
213+
self.new_to_old = dict((new, old) for (old, new) in old_to_new.items())
213214

214215
def find_module(self, fullname, path=None):
215216
# Handles hierarchical importing: package.module.module2
216-
new_base_names = {s.split('.')[0] for s in self.new_to_old}
217+
new_base_names = set([s.split('.')[0] for s in self.new_to_old])
217218
if fullname in set(self.old_to_new) | new_base_names:
218219
return self
219220
return None

future/standard_library/_markupbase.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Backported for python-future from Python 3.3. Reason: ParserBase is an
44
old-style class in the Python 2.7 source of markupbase.py, which I suspect
55
might be the cause of sporadic unit-test failures on travis-ci.org with
6-
test_htmlparser.py. The test failures like like this:
6+
test_htmlparser.py. The test failures look like this:
77
88
======================================================================
99
@@ -153,7 +153,7 @@ def parse_declaration(self, i):
153153
# this could be handled in a separate doctype parser
154154
if decltype == "doctype":
155155
j = self._parse_doctype_subset(j + 1, i)
156-
elif decltype in {"attlist", "linktype", "link", "element"}:
156+
elif decltype in set(["attlist", "linktype", "link", "element"]):
157157
# must tolerate []'d groups in a content model in an element declaration
158158
# also in data attribute specifications of attlist declaration
159159
# also link type declaration subsets in linktype declarations
@@ -176,10 +176,10 @@ def parse_marked_section(self, i, report=1):
176176
sectName, j = self._scan_name( i+3, i )
177177
if j < 0:
178178
return j
179-
if sectName in {"temp", "cdata", "ignore", "include", "rcdata"}:
179+
if sectName in set(["temp", "cdata", "ignore", "include", "rcdata"]):
180180
# look for standard ]]> ending
181181
match= _markedsectionclose.search(rawdata, i+3)
182-
elif sectName in {"if", "else", "endif"}:
182+
elif sectName in set(["if", "else", "endif"]):
183183
# look for MS Office ]> ending
184184
match= _msmarkedsectionclose.search(rawdata, i+3)
185185
else:
@@ -234,7 +234,7 @@ def _parse_doctype_subset(self, i, declstartpos):
234234
name, j = self._scan_name(j + 2, declstartpos)
235235
if j == -1:
236236
return -1
237-
if name not in {"attlist", "element", "entity", "notation"}:
237+
if name not in set(["attlist", "element", "entity", "notation"]):
238238
self.updatepos(declstartpos, j + 2)
239239
self.error(
240240
"unknown declaration %r in internal subset" % name)

future/standard_library/test/regrtest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,11 @@ def work():
677677
'test_doctest2',
678678
]
679679

680-
NOTTESTS = {
680+
NOTTESTS = set([
681681
'test_support',
682682
'test_future1',
683683
'test_future2',
684-
}
684+
])
685685

686686
def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
687687
"""Return a list of all applicable test modules."""

future/standard_library/test/string_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def checkequal(self, result, obj, methodname, *args, **kwargs):
6363
result = self.fixtype(result)
6464
obj = self.fixtype(obj)
6565
args = self.fixtype(args)
66-
kwargs = {k: self.fixtype(v) for k,v in kwargs.items()}
66+
kwargs = dict((k, self.fixtype(v)) for k,v in kwargs.items())
6767
realresult = getattr(obj, methodname)(*args, **kwargs)
6868
self.assertEqual(
6969
result,

future/tests/test_bytes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def test_hash(self):
324324
# This should overwrite d[native_s] again:
325325
d[s] = s
326326
self.assertEqual(len(d), 2)
327-
self.assertEqual(set(d.keys()), {s, b})
327+
self.assertEqual(set(d.keys()), set([s, b]))
328328

329329
@unittest.expectedFailure
330330
def test_hash_with_native_types(self):

future/tests/test_import_star.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
original_locals = set(copy.copy(locals()))
2121
original_globals = set(copy.copy(globals()))
22-
new_names = {'original_locals', 'original_globals', 'new_names'}
22+
new_names = set(['original_locals', 'original_globals', 'new_names'])
2323
from future.builtins import *
2424
new_locals = set(copy.copy(locals())) - new_names - original_locals
2525
new_globals = set(copy.copy(globals())) - new_names - original_globals - \
26-
{'new_locals'}
26+
set(['new_locals'])
2727

2828

2929
class TestImportStar(unittest.TestCase):

0 commit comments

Comments
 (0)
0