Skip to content

Keep webmapper importable on Python 3.13 (cgi removed) - #49

Merged
malloch merged 1 commit into
libmapper:mainfrom
kasparovabi:fix/py313-cgi
Nov 20, 2026
Merged

malloch merged 1 commit into
libmapper:mainfrom
kasparovabi:fix/py313-cgi

Conversation

@kasparovabi

Copy link
Copy Markdown
Contributor

On Python 3.13 python3 webmapper.py exits before the server starts, because webmapper_http_server.py imports cgi at module level and PEP 594 removed that module in 3.13. CI still builds with 3.11, so it does not show up there.

The only user of cgi is MprHTTPServer.do_POST, so this change moves the import into that method. Nothing else changes.

What I ran, in python:3.13-slim with libmapper==2.6.1, mappersession==0.0.18 and netifaces==0.11.0 from requirements.txt, using python webmapper.py --no-browser --stay-alive --iface lo --port 50123 and then a GET /:

main         ModuleNotFoundError: No module named 'cgi'   (webmapper_http_server.py, line 8)
this branch  GET / -> 200, 3455 bytes

Something I noticed while checking do_POST. It already fails on every Python 3 version before it reaches cgi, because self.headers.getheader() is the Python 2 API. A multipart POST /load on 3.11 gives AttributeError: 'HTTPMessage' object has no attribute 'getheader' on main and on this branch alike. I could not find a caller for on_load() in js/MapProperties.js, the only form that posts to /load, so I left the handler as it is. If you want it removed or ported off cgi, I can do that in a separate PR.

Happy to adjust this or close it if it does not fit the project.

The cgi module was removed in Python 3.13 (PEP 594). webmapper_http_server.py
imported it at module level, so webmapper.py exited with
ModuleNotFoundError before the server started. Only do_POST uses cgi, so the
import moves into that method.
@malloch
malloch merged commit 46f29a4 into libmapper:main Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants