Sfoglia il codice sorgente

cgi.parse_qs is deprecated in favor of urlparse.parse_qs in python 2.6,
but the function in urlparse doesn't exist in earlier versions.

Dave Borowitz 15 anni fa
parent
commit
f65845908c
2 ha cambiato i file con 13 aggiunte e 5 eliminazioni
  1. 8 3
      dulwich/misc.py
  2. 5 2
      dulwich/web.py

+ 8 - 3
dulwich/misc.py

@@ -15,15 +15,21 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
-"""Misc utilities to work with python2.4.
+"""Misc utilities to work with python <2.6.
 
 These utilities can all be deleted when dulwich decides it wants to stop
-support for python 2.4.
+support for python <2.6.
 """
 try:
     import hashlib
 except ImportError:
     import sha
+
+try:
+    from urlparse import parse_qs
+except ImportError:
+    from cgi import parse_qs
+
 import struct
 
 
@@ -87,4 +93,3 @@ def unpack_from(fmt, buf, offset=0):
     except AttributeError:
         b = buf[offset:offset+struct.calcsize(fmt)]
         return struct.unpack(fmt, b)
-

+ 5 - 2
dulwich/web.py

@@ -21,8 +21,11 @@
 from cStringIO import StringIO
 import re
 import time
-import urlparse
 
+try:
+    from urlparse import parse_qs
+except ImportError:
+    from dulwich.misc import parse_qs
 from dulwich.server import (
     ReceivePackHandler,
     UploadPackHandler,
@@ -125,7 +128,7 @@ default_services = {'git-upload-pack': UploadPackHandler,
 def get_info_refs(req, backend, mat, services=None):
     if services is None:
         services = default_services
-    params = urlparse.parse_qs(req.environ['QUERY_STRING'])
+    params = parse_qs(req.environ['QUERY_STRING'])
     service = params.get('service', [None])[0]
     if service and not req.dumb:
         handler_cls = services.get(service, None)