Skip to content

Commit

Permalink
fix: remove use of deprecated cgi module (#1006)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Gorcester <gorcester@google.com>
  • Loading branch information
adamchainz and andrewsg committed Mar 29, 2023
1 parent 0ffb3e2 commit 3071832
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""

import base64
import cgi
import copy
import hashlib
from io import BytesIO
Expand All @@ -27,6 +26,7 @@
import mimetypes
import os
import re
from email.parser import HeaderParser
from urllib.parse import parse_qsl
from urllib.parse import quote
from urllib.parse import urlencode
Expand Down Expand Up @@ -1628,7 +1628,8 @@ def download_as_text(
return data.decode(encoding)

if self.content_type is not None:
_, params = cgi.parse_header(self.content_type)
msg = HeaderParser().parsestr("Content-Type: " + self.content_type)
params = dict(msg.get_params()[1:])
if "charset" in params:
return data.decode(params["charset"])

Expand Down

0 comments on commit 3071832

Please sign in to comment.