#3966 python cgi module will be dropped in 3.13
Closed: Fixed by mikem. Opened by tkopecek.

https://peps.python.org/pep-0594/#cgi


Note, that suggested https://pypi.org/project/multipart/ is not the same as python3-multipart included in fedora.

Metadata Update from @tkopecek:
- Custom field Size adjusted to None

Metadata Update from @tkopecek:
- Issue set to the milestone: 1.36 (was: 1.35)

3.13 will be the default python in F41, which expected next month

https://fedoraproject.org/wiki/Changes/Python3.13
https://fedorapeople.org/groups/schedule/f-41/f-41-key-tasks.html

I was concerned about the possibility of POST requests, but it looks like all of our code uses GET requests against the web ui. That means this comment from the cgi module page applies:

The FieldStorage class can typically be replaced with urllib.parse.parse_qsl() for GET and HEAD requests

If I've missed something and we do need to support POST requests for the web ui, then that complicates things. The comment about using "email.message module or multipart for POST and PUT" from the cgi module page is apparently glossing over a large mess. I'd rather not have to go there.

Has there been progress on this? I do realize it's day 1, but Koji is inoperable in Fedora 41 (private instance).

It seems there's an additional layer to this. The Cheetah.Template module unconditionally imports cgi.

  File "/koji/www/kojiweb/wsgi_publisher.py", line 288, in setup
    self._setup(environ)
    ~~~~~~~~~~~^^^^^^^^^
  File "/koji/www/kojiweb/wsgi_publisher.py", line 279, in _setup
    import index as kojiweb_handlers
  File "/koji/www/kojiweb/index.py", line 37, in <module>
    import kojiweb.util
  File "/koji/www/lib/kojiweb/util.py", line 34, in <module>
    import Cheetah.Template
  File "/usr/lib64/python3.13/site-packages/Cheetah/Template.py", line 24, in <module>
    import cgi  # Used by .webInput() if the template is a CGI script.
    ^^^^^^^^^^
ModuleNotFoundError: No module named 'cgi'

It looks like this is only used in very narrow circumstances that we should not hit, but this will still need to be addressed separately.

There is an upstream "fix" here -- https://github.com/CheetahTemplate3/cheetah3/issues/57

There are other 3.13 issues in Cheetah as well and upstream doesn't have a release yet
https://github.com/CheetahTemplate3/cheetah3/issues/63

I've filed https://bugzilla.redhat.com/show_bug.cgi?id=2322559

Potential fix in #4251
Will take some effort to properly test since most of the complex form data involves authenticated actions.

Metadata Update from @mikem:
- Issue set to the milestone: 1.35.2 (was: 1.36)

Metadata Update from @mfilip:
- Issue tagged with: testing-ready

Metadata Update from @mfilip:
- Issue tagged with: testing-done

Commit ac22ca9a fixes this issue

Commit 4eecaddb fixes this issue

Fedora backport PR -- https://src.fedoraproject.org/rpms/koji/pull-request/20

Thank you @mikem for working on this. Just a note, it looks like the release-engineering folks may also need inspiration, as they've chosen to use python3-legacy-cgi for as long as possible rather than working on this technical debt.

https://github.com/release-engineering/dist-git/issues/64
https://bugzilla.redhat.com/show_bug.cgi?id=2300623

I can confirm that at least for now with the Fedora 41 released version of koji, python3-legacy-cgi does temporarily resolve the issue.

This issue has been migrated to Fedora Forge:
https://forge.fedoraproject.org/koji/koji/issues/3966

Please continue any further discussion there.

Metadata
Related Pull Requests