@@ -223,17 +223,17 @@ def parse_multipart(fp, pdict):
223223 """
224224 import http .client
225225
226- boundary = ""
226+ boundary = b ""
227227 if 'boundary' in pdict :
228228 boundary = pdict ['boundary' ]
229229 if not valid_boundary (boundary ):
230230 raise ValueError ('Invalid boundary in multipart form: %r'
231231 % (boundary ,))
232232
233- nextpart = "--" + boundary
234- lastpart = "--" + boundary + "--"
233+ nextpart = b "--" + boundary
234+ lastpart = b "--" + boundary + b "--"
235235 partdict = {}
236- terminator = ""
236+ terminator = b ""
237237
238238 while terminator != lastpart :
239239 bytes = - 1
@@ -252,15 +252,15 @@ def parse_multipart(fp, pdict):
252252 raise ValueError ('Maximum content length exceeded' )
253253 data = fp .read (bytes )
254254 else :
255- data = ""
255+ data = b ""
256256 # Read lines until end of part.
257257 lines = []
258258 while 1 :
259259 line = fp .readline ()
260260 if not line :
261261 terminator = lastpart # End outer loop
262262 break
263- if line .startswith ("--" ):
263+ if line .startswith (b "--" ):
264264 terminator = line .rstrip ()
265265 if terminator in (nextpart , lastpart ):
266266 break
@@ -272,12 +272,12 @@ def parse_multipart(fp, pdict):
272272 if lines :
273273 # Strip final line terminator
274274 line = lines [- 1 ]
275- if line [- 2 :] == "\r \n " :
275+ if line [- 2 :] == b "\r \n " :
276276 line = line [:- 2 ]
277- elif line [- 1 :] == "\n " :
277+ elif line [- 1 :] == b "\n " :
278278 line = line [:- 1 ]
279279 lines [- 1 ] = line
280- data = "" .join (lines )
280+ data = b "" .join (lines )
281281 line = headers ['content-disposition' ]
282282 if not line :
283283 continue
0 commit comments