]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Use urllib.parse_qsl() in Python 2.6 and above,
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 21 Jun 2011 22:34:14 +0000 (18:34 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 21 Jun 2011 22:34:14 +0000 (18:34 -0400)
no deprecation warning about cgi.parse_qsl()
[ticket:1682]

CHANGES
lib/sqlalchemy/engine/url.py
lib/sqlalchemy/util/__init__.py
lib/sqlalchemy/util/compat.py

diff --git a/CHANGES b/CHANGES
index 09f45d58bc602d16b21359f1c5eea70060193d2e..49fa1e576f7bedd54278a3aba04cf93b84ee4238 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -29,6 +29,11 @@ CHANGES
     after from_statement() were called.
     [ticket:2199].  Also in 0.6.9.
 
+- engine
+  - Use urllib.parse_qsl() in Python 2.6 and above,
+    no deprecation warning about cgi.parse_qsl()
+    [ticket:1682]
+
 - mssql
   - Adjusted the pyodbc dialect such that bound
     values are passed as bytes and not unicode
index 7d5e0692f794581ee358bf1f3773b220c8452bd3..0734f6035fdda4bd7aed277056b25e5bd9211665 100644 (file)
@@ -12,8 +12,8 @@ with a string argument; alternatively, the URL is a public-facing construct whic
 be used directly and is also accepted directly by ``create_engine()``.
 """
 
-import re, cgi, sys, urllib
-from sqlalchemy import exc
+import re, urllib
+from sqlalchemy import exc, util
 
 
 class URL(object):
@@ -193,7 +193,7 @@ def _parse_rfc1738_args(name):
         if components['database'] is not None:
             tokens = components['database'].split('?', 2)
             components['database'] = tokens[0]
-            query = (len(tokens) > 1 and dict(cgi.parse_qsl(tokens[1]))) or None
+            query = (len(tokens) > 1 and dict(util.parse_qsl(tokens[1]))) or None
             # Py2K
             if query is not None:
                 query = dict((k.encode('ascii'), query[k]) for k in query)
@@ -215,7 +215,7 @@ def _parse_keyvalue_args(name):
     m = re.match( r'(\w+)://(.*)', name)
     if m is not None:
         (name, args) = m.group(1, 2)
-        opts = dict( cgi.parse_qsl( args ) )
+        opts = dict( util.parse_qsl( args ) )
         return URL(name, *opts)
     else:
         return None
index 93c418edae85fc3a907c1dfd6c9ef17c153209e6..827fce088d0d8517632caf5c68204765450968cb 100644 (file)
@@ -6,7 +6,8 @@
 
 from compat import callable, cmp, reduce, defaultdict, py25_dict, \
     threading, py3k, jython, pypy, win32, set_types, buffer, pickle, \
-    update_wrapper, partial, md5_hex, decode_slice, dottedgetter
+    update_wrapper, partial, md5_hex, decode_slice, dottedgetter,\
+    parse_qsl
 
 from _collections import NamedTuple, ImmutableContainer, immutabledict, \
     Properties, OrderedProperties, ImmutableProperties, OrderedDict, \
index 69d648498a666ea9938a9e5ba73c96c461772290..866c0c2167335ce7113ef7529045c7029d1ca379 100644 (file)
@@ -81,6 +81,14 @@ except ImportError:
             return func(*(args + fargs), **newkeywords)
         return newfunc
 
+
+if sys.version_info < (2, 6):
+    # emits a nasty deprecation warning
+    # in newer pythons
+    from cgi import parse_qsl
+else:
+    from urlparse import parse_qsl
+
 if py3k:
     # they're bringing it back in 3.2.  brilliant !
     def callable(fn):