Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

backward compatibility edits #2

Closed
wants to merge 1 commit into from

3 participants

@colevscode

removed new style dictionary comprehensions not available in python versions before 2.7 (for lazy mac users... like me!)

Cole Krumbholz removed new style dictionary comprehensions not available in python v…
…ersions before 2.7 (for lazy mac users... like me!)
e6c1f4c
@gruns
Owner

Is it hard to install multiple versions of Python and separate them cleanly with virtualenv on a Mac?

@colevscode colevscode closed this
@kmike

Python 2.6 support is important because at least latest Debian (Squeeze), Ubuntu LTS, RHEL and CentOS use python 2.6. In case of Red Hat developers may be stuck with python 2.6 for a long time because next RHEL is scheduled only for 2013; many developers can't update their python on RHEL manually because of support contracts.

@gruns gruns reopened this
@gruns
Owner

Swapped out the dictionary comprehensions for Python 2.6 compatible dict() constructor + list comprehensions.

Thanks for the commit, suggestion, and information colevscode and kmike.

@gruns gruns closed this
@gruns gruns referenced this pull request from a commit
Arthur Grunseid Test bolden URL components #2. a08693a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2011
  1. removed new style dictionary comprehensions not available in python v…

    Cole Krumbholz authored
    …ersions before 2.7 (for lazy mac users... like me!)
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 3 deletions.
  1. +9 −3 furl.py
View
12 furl.py 100644 → 100755
@@ -167,7 +167,8 @@ 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()}
+ for k, v in query.iteritems():
+ self.params[k]=urllib.unquote_plus(v)
else:
self.params = parse_qs(query)
@@ -191,7 +192,9 @@ def remove(self, query=None):
return self
def __str__(self):
- params = {str(key):str(val) for key, val in self.params.iteritems()}
+ params = {}
+ for key, val in self.params.iteritems():
+ params[str(key)] = str(val)
return urllib.urlencode(params)
def __repr__(self):
@@ -665,7 +668,10 @@ 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()}
+ rval = {}
+ for key, val in urlparse.parse_qs(query).iteritems():
+ rval[key] = val[0]
+ return rval
def urlsplit(url):
"""
Something went wrong with that request. Please try again.