Open
Description
Hi there,
First off, thank you for this amazing library! I recently wrote a blog post demonstrating how to use Django as a service provider, with pysaml2 serving as an example IdP. A reader has since pointed out that it doesn’t work with Python 3.13, and after some investigation, I suspect the issue stems from the removal of the cgi module in Python 3.13.
I noticed that pysaml2 still imports cgi in a couple of places. For example:
In src/saml2/httputil.py:
# The `cgi` module is used here:
formdata = cgi.parse(environ["wsgi.input"], environ, empty, err)
# Since `parse_qs` is already imported, this could potentially be replaced with:
input_stream = environ["wsgi.input"]
content_length = int(environ.get("CONTENT_LENGTH", 0))
form_data_bytes = input_stream.read(content_length)
form_data = parse_qs(form_data_bytes.decode('utf-8'))
In src/saml2/pack.py and src/saml2/httputil.py:
# The fallback to `cgi` for HTML escaping could be removed, as the `html` module
# (introduced in Python 3.4) provides the necessary functionality:
try:
import html
except Exception:
import cgi as html # type: ignore[no-redef]
Would it make sense to update these references to make pysaml2 compatible with Python 3.13? I’d be happy to help test any changes.
Best regards,
Jochen
Metadata
Metadata
Assignees
Labels
No labels