Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Consistent imports for parse_qsl function, avoiding the `PendingDepre…

…cationWarning` under Python 2.6 and later

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14297 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6be00774a4d65fc4d84c297ca6bd36c9c86fbca9 1 parent 40a2a1c
Luke Plant authored October 20, 2010
11  django/core/cache/__init__.py
@@ -16,9 +16,16 @@
16 16
 """
17 17
 
18 18
 try:
19  
-    from urlparse import parse_qsl
  19
+    # The mod_python version is more efficient, so try importing it first.
  20
+    from mod_python.util import parse_qsl
20 21
 except ImportError:
21  
-    from cgi import parse_qsl
  22
+    try:
  23
+        # Python 2.6 and greater
  24
+        from urlparse import parse_qsl
  25
+    except ImportError:
  26
+        # Python 2.5, 2.4.  Works on Python 2.6 but raises
  27
+        # PendingDeprecationWarning
  28
+        from cgi import parse_qsl
22 29
 
23 30
 from django.conf import settings
24 31
 from django.core import signals
8  django/http/__init__.py
@@ -10,7 +10,13 @@
10 10
     # The mod_python version is more efficient, so try importing it first.
11 11
     from mod_python.util import parse_qsl
12 12
 except ImportError:
13  
-    from cgi import parse_qsl
  13
+    try:
  14
+        # Python 2.6 and greater
  15
+        from urlparse import parse_qsl
  16
+    except ImportError:
  17
+        # Python 2.5, 2.4.  Works on Python 2.6 but raises
  18
+        # PendingDeprecationWarning
  19
+        from cgi import parse_qsl
14 20
 
15 21
 from django.utils.datastructures import MultiValueDict, ImmutableList
16 22
 from django.utils.encoding import smart_str, iri_to_uri, force_unicode

0 notes on commit 6be0077

Please sign in to comment.
Something went wrong with that request. Please try again.