Remove support for cgi.FieldStorage
The python cgi module is being removed in python 3.13[1]. This patch moves the use of cgi.FieldStorage under a try block that will skip the check for cgi.FieldStorage object in File type parsing. [1] https://docs.python.org/3/library/cgi.html Change-Id: Iff145680312c3aba18b5be078fbf1ea32b06080b
This commit is contained in:
parent
4c0da145f2
commit
f22cde6973
@ -1,4 +1,3 @@
|
|||||||
import cgi
|
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -36,8 +35,13 @@ def datetime_from_param(datatype, value):
|
|||||||
|
|
||||||
@from_param.when_object(File)
|
@from_param.when_object(File)
|
||||||
def filetype_from_param(datatype, value):
|
def filetype_from_param(datatype, value):
|
||||||
if isinstance(value, cgi.FieldStorage):
|
# TODO(johnsom) Remove once python 3.13 is the minimum supported version.
|
||||||
return File(fieldstorage=value)
|
try:
|
||||||
|
import cgi
|
||||||
|
if isinstance(value, cgi.FieldStorage):
|
||||||
|
return File(fieldstorage=value)
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
return File(content=value)
|
return File(content=value)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user