diff --git a/docs/third_party_packages.md b/docs/third_party_packages.md index 2adb53ae56..3d5f4778ec 100644 --- a/docs/third_party_packages.md +++ b/docs/third_party_packages.md @@ -8,7 +8,7 @@ As HTTPX usage grows, there is an expanding community of developers building too ### Hishel -[GitHub](https://github.com/karosis88/hishel) - [Documentation](https://karosis88.github.io/hishel/) +[GitHub](https://github.com/karpetrosyan/hishel) - [Documentation](https://hishel.com/) An elegant HTTP Cache implementation for HTTPX and HTTP Core. diff --git a/httpx/_auth.py b/httpx/_auth.py index 27dc7f743b..c2c38f3945 100644 --- a/httpx/_auth.py +++ b/httpx/_auth.py @@ -1,5 +1,4 @@ import hashlib -import netrc import os import re import time @@ -148,6 +147,10 @@ class NetRCAuth(Auth): """ def __init__(self, file: typing.Optional[str] = None): + # Lazily import 'netrc'. + # There's no need for us to load this module unless 'NetRCAuth' is being used. + import netrc + self._netrc_info = netrc.netrc(file) def auth_flow(self, request: Request) -> typing.Generator[Request, Response, None]: diff --git a/httpx/_multipart.py b/httpx/_multipart.py index 446f4ad2df..6d5baa8639 100644 --- a/httpx/_multipart.py +++ b/httpx/_multipart.py @@ -1,4 +1,3 @@ -import binascii import io import os import typing @@ -200,7 +199,7 @@ def __init__( 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(