Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 708513f

Browse files
authored
Merge pull request #4 from EdwardBetts/cgi-is-deprecated
Stop using the cgi module, it is deprecated
2 parents 74012d0 + 0b417c7 commit 708513f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pantomime/parse.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cgi import parse_header
1+
from email.message import EmailMessage
22
from typing import Any, Dict, Optional, Tuple
33
from normality import stringify
44
from normality.encoding import tidy_encoding
@@ -62,7 +62,10 @@ def parse(
6262
mime_type = stringify(mime_type)
6363
params = None
6464
if mime_type is not None:
65-
mime_type, params = parse_header(mime_type)
65+
msg = EmailMessage()
66+
msg['content-type'] = mime_type
67+
mime_type = msg.get_content_type() if mime_type.count("/") == 1 else None
68+
params = msg['content-type'].params
6669

6770
family, subtype = cls.split(mime_type)
6871
if family is None:

0 commit comments

Comments
 (0)