Permalink
Browse files

Removed dictionary comprehensions for compatibility with Python 2.6 a…

…nd earlier.
  • Loading branch information...
Arthur Grunseid
Arthur Grunseid committed Dec 14, 2011
1 parent fa4e53c commit 91692ecae347a8f14c198387cc05bbd0dde61bee
Showing with 7 additions and 3 deletions.
  1. +7 −3 furl/furl.py
View
@@ -167,7 +167,9 @@ def __init__(self, query=None):
def parse(self, query):
if isinstance(query, dict):
- self.params = {k:urllib.unquote_plus(v) for k, v in query.iteritems()}
+ # py2.7+: {k:urllib.unquote_plus(v) for k, v in query.iteritems()}
+ tmp = dict((k,urllib.unquote_plus(v)) for (k,v) in query.iteritems())
+ self.params = tmp
else:
self.params = parse_qs(query)
@@ -191,7 +193,8 @@ def remove(self, query=None):
return self
def __str__(self):
- params = {str(key):str(val) for key, val in self.params.iteritems()}
+ # py2.7+: {str(key):str(val) for key, val in self.params.iteritems()}
+ params = dict((str(key),str(val)) for (key,val) in self.params.iteritems())
return urllib.urlencode(params)
def __repr__(self):
@@ -665,7 +668,8 @@ def parse_qs(query):
Parse a query string to a dictionary of parameter key:value pairs, removing
any duplicate url parameters. I.e. 'a=1&a=2' would become {'a':'1'}.
"""
- return {key:val[0] for key, val in urlparse.parse_qs(query).iteritems()}
+ # py2.7+: {key:val[0] for key, val in urlparse.parse_qs(query).iteritems()}
+ return dict((k,v[0]) for (k,v) in urlparse.parse_qs(query).iteritems())
def urlsplit(url):
"""

0 comments on commit 91692ec

Please sign in to comment.