mod_python icon indicating copy to clipboard operation
mod_python copied to clipboard

cgi escape will not import

Open henrythemouse opened this issue 5 years ago • 5 comments

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?

henrythemouse avatar Dec 01 '20 00:12 henrythemouse

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=975608 which has a patch attached for the Debian version.

wom-bat avatar Feb 04 '21 02:02 wom-bat

Thank you, the patch does the trick.

henrythemouse avatar Feb 04 '21 07:02 henrythemouse

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

henrythemouse avatar Jul 26 '21 18:07 henrythemouse

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).

grisha avatar Jul 26 '21 18:07 grisha

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.

henrythemouse avatar Jul 26 '21 19:07 henrythemouse