cgi escape will not import
Hi,
I'm trying to convert my python2 app to python3. It uses mod-python on debian. I have a sid vm that I'm using to experiment with, which supplies mod-python 3.5.0-1+b1.
I've run into an error that seems rooted in python3.8, sid is currently using python3.9.
File "/usr/lib/python3/dist-packages/mod_python/psp.py", line 28, in <module> from cgi import escape ImportError: cannot import name 'escape' from 'cgi' (/usr/lib/python3.9/cgi.py)
I'm writing to see if this has been resolved in the git repo? Or maybe there is a work around? I read online that the program 'supervisor' may have patched this somehow in python3.8. I installed that, but no difference.
Anyone have any idea what I could do?
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=975608 which has a patch attached for the Debian version.
Thank you, the patch does the trick.
Just a update concerning this issue,
I decided to compile mod_python. The compile worked fine, as did the install. When I tried to use it, I got the same error that caused me to submit this issue in the fist place. The problem of cgi moving to the html module . It was fixed in apache.py (in the git clone I did for this build), but not in psp.py. I copied the fix from apache.py to psp.py. That fixed this issue.
It would be nice if someone could update the psp.py file in git, Seems like there is still some interest in mod_python.
The psp module had not been updated
-from cgi import escape
+try:
+ from html import escape
+except:
+ from cgi import escape
Good catch - could you make a pull request with this change? (If not I'll figure something out - but a pull request will give you proper credit for the fix).
A pull request (104) was submitted 6 days ago, for a general fix of the cgi issue. I went ahead and created a new one for this specific issue, hopefully that works for you. Let me know if I didn't do something correctly, thanks.