1
1
import io
2
- import warnings
3
2
from typing import Any , Iterable , List , Optional
4
3
from urllib .parse import urlencode
5
4
@@ -50,18 +49,9 @@ def add_field(
50
49
* ,
51
50
content_type : Optional [str ] = None ,
52
51
filename : Optional [str ] = None ,
53
- content_transfer_encoding : Optional [str ] = None ,
54
52
) -> None :
55
- if isinstance (value , io .IOBase ):
53
+ if isinstance (value , ( io .IOBase , bytes , bytearray , memoryview ) ):
56
54
self ._is_multipart = True
57
- elif isinstance (value , (bytes , bytearray , memoryview )):
58
- msg = (
59
- "In v4, passing bytes will no longer create a file field. "
60
- "Please explicitly use the filename parameter or pass a BytesIO object."
61
- )
62
- if filename is None and content_transfer_encoding is None :
63
- warnings .warn (msg , DeprecationWarning )
64
- filename = name
65
55
66
56
type_options : MultiDict [str ] = MultiDict ({"name" : name })
67
57
if filename is not None and not isinstance (filename , str ):
@@ -82,18 +72,6 @@ def add_field(
82
72
)
83
73
headers [hdrs .CONTENT_TYPE ] = content_type
84
74
self ._is_multipart = True
85
- if content_transfer_encoding is not None :
86
- if not isinstance (content_transfer_encoding , str ):
87
- raise TypeError (
88
- "content_transfer_encoding must be an instance"
89
- " of str. Got: %s" % content_transfer_encoding
90
- )
91
- msg = (
92
- "content_transfer_encoding is deprecated. "
93
- "To maintain compatibility with v4 please pass a BytesPayload."
94
- )
95
- warnings .warn (msg , DeprecationWarning )
96
- self ._is_multipart = True
97
75
98
76
self ._fields .append ((type_options , headers , value ))
99
77
0 commit comments