Using email module as a replacement for CGI?

The deprecation documentation for the CGI module currently recommends two paths forward when it comes to parsing POST request bodies going forward:

  • 3rd-party library multipart
  • Standard-library email.message

I’m wondering if the latter is really appropriate to recommend, given how non-obvious and non-trivial the implementation of that seems to actually be.

I’d like to propose either removing that bit of phrasing (that suggests email be used) to avoid throwing new programmers into a tarpit, or adding a HOWTO page targeting the average person googling “python cgi deprecated how to parse file form upload 2023”.


Porting this over from elsewhere—

It would at least be interesting to better understand why using email.message is so cumbersome. Is there a way to use an email policy to make the job easier?