Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

updated deprecated cgi.parse_qsl to use six's parse_qsl

VKen33a7c1d43809
diff --git a/scrapy/utils/url.py b/scrapy/utils/url.py
index ab4d75f87..36490a39d 100644
--- a/scrapy/utils/url.py
+++ b/scrapy/utils/url.py
@@ -6,9 +6,9 @@ Some of the functions that used to be imported from this module have been moved
to the w3lib.url module. Always import those from there instead.
"""
import posixpath
-from six.moves.urllib.parse import ParseResult, urlunparse, urldefrag, urlparse
+from six.moves.urllib.parse import (ParseResult, urlunparse, urldefrag,
+ urlparse, parse_qsl)
import urllib
-import cgi
# scrapy.utils.url was moved to w3lib.url and import * ensures this move doesn't break old code
from w3lib.url import *
@@ -54,7 +54,7 @@ def canonicalize_url(url, keep_blank_values=True, keep_fragments=False,
"""
scheme, netloc, path, params, query, fragment = parse_url(url)
- keyvals = cgi.parse_qsl(query, keep_blank_values)
+ keyvals = parse_qsl(query, keep_blank_values)
keyvals.sort()
query = urllib.urlencode(keyvals)
path = safe_url_string(_unquotepath(path)) or '/'