ZeroNet icon indicating copy to clipboard operation
ZeroNet copied to clipboard

AttributeError: module 'cgi' has no attribute 'parse_qsl' in UiServer.py line 41 > pywsgi.py line 945 > UiServer.py line 98

Open yurivict opened this issue 4 years ago • 3 comments

Step 1: Please describe your environment

FreeBSD 13 with python-38

Step 2: Describe the problem:

Errors:

[22:32:31] - UiWSGIHandler error: AttributeError: module 'cgi' has no attribute 'parse_qsl' in UiServer.py line 41 > pywsgi.py line 945 > UiServer.py line 98
[22:32:31] - UiWSGIHandler error: AttributeError: module 'cgi' has no attribute 'parse_qsl' in UiServer.py line 41 > pywsgi.py line 945 > UiServer.py line 98

cgi.parse_qsl is deprecated and removed.

yurivict avatar May 22 '21 05:05 yurivict

Here is the patch:

--- src/Ui/UiServer.py.orig     2019-09-04 18:16:57 UTC
+++ src/Ui/UiServer.py
@@ -4,6 +4,7 @@ import cgi
 import socket
 import sys
 import gevent
+import urllib
 
 from gevent.pywsgi import WSGIServer
 from gevent.pywsgi import WSGIHandler
@@ -95,7 +96,7 @@ class UiServer:
     def handleRequest(self, env, start_response):
         path = bytes(env["PATH_INFO"], "raw-unicode-escape").decode("utf8")
         if env.get("QUERY_STRING"):
-            get = dict(cgi.parse_qsl(env['QUERY_STRING']))
+            get = dict(urllib.parse.parse_qsl(env['QUERY_STRING']))
         else:
             get = {}
         ui_request = UiRequest(self, get, env, start_response)

yurivict avatar May 22 '21 05:05 yurivict

Experieced this too on Manjaro with python3 == 3.9.

PRESFIL avatar Jun 05 '21 17:06 PRESFIL

For reference:

@Tio cgi.parse_qsl has been deprecated since Python 3.2 and been removed in Python 3.8 This problem has been fixed in the latest commit of upstream but not yet released. https://docs.python.org/3.8/whatsnew/3.8.html#api-and-feature-removals -- TJM @ AUR https://aur.archlinux.org/packages/zeronet/#comment-766256

PRESFIL avatar Jun 05 '21 17:06 PRESFIL