Skip to content

Commit

Permalink
Merge pull request #340 from mtreinish/no-more-cgi
Browse files Browse the repository at this point in the history
Replace deprecated `cgi` module usage with `email`
  • Loading branch information
cjwatson committed Mar 14, 2023
2 parents 89ed130 + 54ea8f2 commit 3eda708
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions testtools/testresult/real.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
'TimestampingStreamResult',
]

import cgi
import datetime
import email
import math
from operator import methodcaller
import sys
Expand Down Expand Up @@ -759,7 +759,10 @@ def _make_content_type(mime_type=None):
if mime_type is None:
mime_type = 'application/octet-stream'

full_type, parameters = cgi.parse_header(mime_type)
msg = email.message.EmailMessage()
msg['content-type'] = mime_type

full_type, parameters = msg.get_content_type(), dict(msg['content-type'].params)
# Ensure any wildcards are valid.
if full_type == '*':
full_type = '*/*'
Expand Down

0 comments on commit 3eda708

Please sign in to comment.