Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Jul 26, 2024
1 parent 33c4d96 commit c6f51c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions httpx/_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def urlparse(url: str = "", **kwargs: str | None) -> ParseResult:
# If a URL includes any ASCII control characters including \t, \r, \n,
# then treat it as invalid.
if any(char.isascii() and not char.isprintable() for char in url):
char = [char for char in url if char.isascii() and not char.isprintable()][0]
char = next(char for char in url if char.isascii() and not char.isprintable())
idx = url.find(char)
error = (
f"Invalid non-printable ASCII character in URL, {char!r} at position {idx}."
Expand Down Expand Up @@ -210,9 +210,9 @@ def urlparse(url: str = "", **kwargs: str | None) -> ParseResult:
# If a component includes any ASCII control characters including \t, \r, \n,
# then treat it as invalid.
if any(char.isascii() and not char.isprintable() for char in value):
char = [
char = next(
char for char in value if char.isascii() and not char.isprintable()
][0]
)
idx = value.find(char)
error = (
f"Invalid non-printable ASCII character in URL {key} component, "
Expand Down

0 comments on commit c6f51c7

Please # to comment.