]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Drop unneccessary `binascii` import (#2909)
authorTom Christie <tom@tomchristie.com>
Mon, 30 Oct 2023 19:13:47 +0000 (19:13 +0000)
committerGitHub <noreply@github.com>
Mon, 30 Oct 2023 19:13:47 +0000 (19:13 +0000)
* Drop unneccessary binascii import

* Update httpx/_multipart.py

Co-authored-by: T-256 <132141463+T-256@users.noreply.github.com>
* boundary is 'bytes' not 'str'

---------

Co-authored-by: T-256 <132141463+T-256@users.noreply.github.com>
httpx/_multipart.py

index 446f4ad2df3eb0b566e11c9aab9bbfc4875edfba..6d5baa86398db97539d2f02435bebc2138a257e4 100644 (file)
@@ -1,4 +1,3 @@
-import binascii
 import io
 import os
 import typing
@@ -200,7 +199,7 @@ class MultipartStream(SyncByteStream, AsyncByteStream):
         boundary: typing.Optional[bytes] = None,
     ) -> None:
         if boundary is None:
-            boundary = binascii.hexlify(os.urandom(16))
+            boundary = os.urandom(16).hex().encode("ascii")
 
         self.boundary = boundary
         self.content_type = "multipart/form-data; boundary=%s" % boundary.decode(