Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions vendor/bin/normalizer
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/home/geekmasher/.local/share/virtualenvs/brew-dependency-submission-action-Gz_oAmoD/bin/python
# -*- coding: utf-8 -*-
import re
#!/home/runner/.local/share/virtualenvs/brew-dependency-submission-action-XUqNX2Tu/bin/python
import sys
from charset_normalizer import cli
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
if sys.argv[0].endswith('.exe'):
sys.argv[0] = sys.argv[0][:-4]
sys.exit(cli.cli_detect())
10 changes: 9 additions & 1 deletion vendor/semantic_version/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@


__author__ = "Raphaël Barrois <[email protected]>"
__version__ = "2.10.0"
try:
# Python 3.8+
from importlib.metadata import version

__version__ = version("semantic_version")
except ImportError:
import pkg_resources

__version__ = pkg_resources.get_distribution("semantic_version").version
4 changes: 2 additions & 2 deletions vendor/urllib3/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE

__version__ = version = '2.4.0'
__version_tuple__ = version_tuple = (2, 4, 0)
__version__ = version = '2.5.0'
__version_tuple__ = version_tuple = (2, 5, 0)
125 changes: 87 additions & 38 deletions vendor/urllib3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class BaseSSLError(BaseException): # type: ignore[no-redef]

# When it comes time to update this value as a part of regular maintenance
# (ie test_recent_date is failing) update it to ~6 months before the current date.
RECENT_DATE = datetime.date(2023, 6, 1)
RECENT_DATE = datetime.date(2025, 1, 1)

_CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]")

Expand Down Expand Up @@ -232,45 +232,94 @@ def set_tunnel(
super().set_tunnel(host, port=port, headers=headers)
self._tunnel_scheme = scheme

if sys.version_info < (3, 11, 4):

def _tunnel(self) -> None:
_MAXLINE = http.client._MAXLINE # type: ignore[attr-defined]
connect = b"CONNECT %s:%d HTTP/1.0\r\n" % ( # type: ignore[str-format]
self._tunnel_host.encode("ascii"), # type: ignore[union-attr]
self._tunnel_port,
)
headers = [connect]
for header, value in self._tunnel_headers.items(): # type: ignore[attr-defined]
headers.append(f"{header}: {value}\r\n".encode("latin-1"))
headers.append(b"\r\n")
# Making a single send() call instead of one per line encourages
# the host OS to use a more optimal packet size instead of
# potentially emitting a series of small packets.
self.send(b"".join(headers))
del headers

response = self.response_class(self.sock, method=self._method) # type: ignore[attr-defined]
try:
(version, code, message) = response._read_status() # type: ignore[attr-defined]

if code != http.HTTPStatus.OK:
self.close()
raise OSError(f"Tunnel connection failed: {code} {message.strip()}")
while True:
line = response.fp.readline(_MAXLINE + 1)
if len(line) > _MAXLINE:
raise http.client.LineTooLong("header line")
if not line:
# for sites which EOF without sending a trailer
break
if line in (b"\r\n", b"\n", b""):
break
if sys.version_info < (3, 11, 9) or ((3, 12) <= sys.version_info < (3, 12, 3)):
# Taken from python/cpython#100986 which was backported in 3.11.9 and 3.12.3.
# When using connection_from_host, host will come without brackets.
def _wrap_ipv6(self, ip: bytes) -> bytes:
if b":" in ip and ip[0] != b"["[0]:
return b"[" + ip + b"]"
return ip

if sys.version_info < (3, 11, 9):
# `_tunnel` copied from 3.11.13 backporting
# https://github.com/python/cpython/commit/0d4026432591d43185568dd31cef6a034c4b9261
# and https://github.com/python/cpython/commit/6fbc61070fda2ffb8889e77e3b24bca4249ab4d1
def _tunnel(self) -> None:
_MAXLINE = http.client._MAXLINE # type: ignore[attr-defined]
connect = b"CONNECT %s:%d HTTP/1.0\r\n" % ( # type: ignore[str-format]
self._wrap_ipv6(self._tunnel_host.encode("ascii")), # type: ignore[union-attr]
self._tunnel_port,
)
headers = [connect]
for header, value in self._tunnel_headers.items(): # type: ignore[attr-defined]
headers.append(f"{header}: {value}\r\n".encode("latin-1"))
headers.append(b"\r\n")
# Making a single send() call instead of one per line encourages
# the host OS to use a more optimal packet size instead of
# potentially emitting a series of small packets.
self.send(b"".join(headers))
del headers

response = self.response_class(self.sock, method=self._method) # type: ignore[attr-defined]
try:
(version, code, message) = response._read_status() # type: ignore[attr-defined]

if code != http.HTTPStatus.OK:
self.close()
raise OSError(
f"Tunnel connection failed: {code} {message.strip()}"
)
while True:
line = response.fp.readline(_MAXLINE + 1)
if len(line) > _MAXLINE:
raise http.client.LineTooLong("header line")
if not line:
# for sites which EOF without sending a trailer
break
if line in (b"\r\n", b"\n", b""):
break

if self.debuglevel > 0:
print("header:", line.decode())
finally:
response.close()

elif (3, 12) <= sys.version_info < (3, 12, 3):
# `_tunnel` copied from 3.12.11 backporting
# https://github.com/python/cpython/commit/23aef575c7629abcd4aaf028ebd226fb41a4b3c8
def _tunnel(self) -> None: # noqa: F811
connect = b"CONNECT %s:%d HTTP/1.1\r\n" % ( # type: ignore[str-format]
self._wrap_ipv6(self._tunnel_host.encode("idna")), # type: ignore[union-attr]
self._tunnel_port,
)
headers = [connect]
for header, value in self._tunnel_headers.items(): # type: ignore[attr-defined]
headers.append(f"{header}: {value}\r\n".encode("latin-1"))
headers.append(b"\r\n")
# Making a single send() call instead of one per line encourages
# the host OS to use a more optimal packet size instead of
# potentially emitting a series of small packets.
self.send(b"".join(headers))
del headers

response = self.response_class(self.sock, method=self._method) # type: ignore[attr-defined]
try:
(version, code, message) = response._read_status() # type: ignore[attr-defined]

self._raw_proxy_headers = http.client._read_headers(response.fp) # type: ignore[attr-defined]

if self.debuglevel > 0:
print("header:", line.decode())
finally:
response.close()
for header in self._raw_proxy_headers:
print("header:", header.decode())

if code != http.HTTPStatus.OK:
self.close()
raise OSError(
f"Tunnel connection failed: {code} {message.strip()}"
)

finally:
response.close()

def connect(self) -> None:
self.sock = self._new_conn()
Expand Down
20 changes: 20 additions & 0 deletions vendor/urllib3/contrib/emscripten/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@ def send_jspi_request(
"method": request.method,
"signal": js_abort_controller.signal,
}
# Node.js returns the whole response (unlike opaqueredirect in browsers),
# so urllib3 can set `redirect: manual` to control redirects itself.
# https://stackoverflow.com/a/78524615
if _is_node_js():
fetch_data["redirect"] = "manual"
# Call JavaScript fetch (async api, returns a promise)
fetcher_promise_js = js.fetch(request.url, _obj_from_dict(fetch_data))
# Now suspend WebAssembly until we resolve that promise
Expand Down Expand Up @@ -693,6 +698,21 @@ def has_jspi() -> bool:
return False


def _is_node_js() -> bool:
"""
Check if we are in Node.js.

:return: True if we are in Node.js.
:rtype: bool
"""
return (
hasattr(js, "process")
and hasattr(js.process, "release")
# According to the Node.js documentation, the release name is always "node".
and js.process.release.name == "node"
)


def streaming_ready() -> bool | None:
if _fetcher:
return _fetcher.streaming_ready
Expand Down
18 changes: 17 additions & 1 deletion vendor/urllib3/poolmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ def __init__(
**connection_pool_kw: typing.Any,
) -> None:
super().__init__(headers)
if "retries" in connection_pool_kw:
retries = connection_pool_kw["retries"]
if not isinstance(retries, Retry):
# When Retry is initialized, raise_on_redirect is based
# on a redirect boolean value.
# But requests made via a pool manager always set
# redirect to False, and raise_on_redirect always ends
# up being False consequently.
# Here we fix the issue by setting raise_on_redirect to
# a value needed by the pool manager without considering
# the redirect boolean.
raise_on_redirect = retries is not False
retries = Retry.from_int(retries, redirect=False)
retries.raise_on_redirect = raise_on_redirect
connection_pool_kw = connection_pool_kw.copy()
connection_pool_kw["retries"] = retries
self.connection_pool_kw = connection_pool_kw

self.pools: RecentlyUsedContainer[PoolKey, HTTPConnectionPool]
Expand Down Expand Up @@ -456,7 +472,7 @@ def urlopen( # type: ignore[override]
kw["body"] = None
kw["headers"] = HTTPHeaderDict(kw["headers"])._prepare_for_method_change()

retries = kw.get("retries")
retries = kw.get("retries", response.retries)
if not isinstance(retries, Retry):
retries = Retry.from_int(retries, redirect=redirect)

Expand Down
77 changes: 53 additions & 24 deletions vendor/urllib3/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,6 @@
except ImportError:
brotli = None

try:
import zstandard as zstd
except (AttributeError, ImportError, ValueError): # Defensive:
HAS_ZSTD = False
else:
# The package 'zstandard' added the 'eof' property starting
# in v0.18.0 which we require to ensure a complete and
# valid zstd stream was fed into the ZstdDecoder.
# See: https://github.com/urllib3/urllib3/pull/2624
_zstd_version = tuple(
map(int, re.search(r"^([0-9]+)\.([0-9]+)", zstd.__version__).groups()) # type: ignore[union-attr]
)
if _zstd_version < (0, 18): # Defensive:
HAS_ZSTD = False
else:
HAS_ZSTD = True

from . import util
from ._base_connection import _TYPE_BODY
from ._collections import HTTPHeaderDict
Expand Down Expand Up @@ -163,27 +146,69 @@ def flush(self) -> bytes:
return b""


if HAS_ZSTD:
try:
# Python 3.14+
from compression import zstd # type: ignore[import-not-found] # noqa: F401

HAS_ZSTD = True

class ZstdDecoder(ContentDecoder):
def __init__(self) -> None:
self._obj = zstd.ZstdDecompressor().decompressobj()
self._obj = zstd.ZstdDecompressor()

def decompress(self, data: bytes) -> bytes:
if not data:
return b""
data_parts = [self._obj.decompress(data)]
while self._obj.eof and self._obj.unused_data:
unused_data = self._obj.unused_data
self._obj = zstd.ZstdDecompressor().decompressobj()
self._obj = zstd.ZstdDecompressor()
data_parts.append(self._obj.decompress(unused_data))
return b"".join(data_parts)

def flush(self) -> bytes:
ret = self._obj.flush() # note: this is a no-op
if not self._obj.eof:
raise DecodeError("Zstandard data is incomplete")
return ret
return b""

except ImportError:
try:
# Python 3.13 and earlier require the 'zstandard' module.
import zstandard as zstd

# The package 'zstandard' added the 'eof' property starting
# in v0.18.0 which we require to ensure a complete and
# valid zstd stream was fed into the ZstdDecoder.
# See: https://github.com/urllib3/urllib3/pull/2624
_zstd_version = tuple(
map(int, re.search(r"^([0-9]+)\.([0-9]+)", zstd.__version__).groups()) # type: ignore[union-attr]
)
if _zstd_version < (0, 18): # Defensive:
raise ImportError("zstandard module doesn't have eof")
except (AttributeError, ImportError, ValueError): # Defensive:
HAS_ZSTD = False
else:
HAS_ZSTD = True

class ZstdDecoder(ContentDecoder): # type: ignore[no-redef]
def __init__(self) -> None:
self._obj = zstd.ZstdDecompressor().decompressobj()

def decompress(self, data: bytes) -> bytes:
if not data:
return b""
data_parts = [self._obj.decompress(data)]
while self._obj.eof and self._obj.unused_data:
unused_data = self._obj.unused_data
self._obj = zstd.ZstdDecompressor().decompressobj()
data_parts.append(self._obj.decompress(unused_data))
return b"".join(data_parts)

def flush(self) -> bytes:
ret = self._obj.flush() # note: this is a no-op
if not self._obj.eof:
raise DecodeError("Zstandard data is incomplete")
return ret # type: ignore[no-any-return]


class MultiDecoder(ContentDecoder):
Expand Down Expand Up @@ -518,7 +543,7 @@ def readinto(self, b: bytearray) -> int:
def getheaders(self) -> HTTPHeaderDict:
warnings.warn(
"HTTPResponse.getheaders() is deprecated and will be removed "
"in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.",
"in urllib3 v2.6.0. Instead access HTTPResponse.headers directly.",
category=DeprecationWarning,
stacklevel=2,
)
Expand All @@ -527,7 +552,7 @@ def getheaders(self) -> HTTPHeaderDict:
def getheader(self, name: str, default: str | None = None) -> str | None:
warnings.warn(
"HTTPResponse.getheader() is deprecated and will be removed "
"in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).",
"in urllib3 v2.6.0. Instead use HTTPResponse.headers.get(name, default).",
category=DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -1075,6 +1100,10 @@ def readable(self) -> bool:
def shutdown(self) -> None:
if not self._sock_shutdown:
raise ValueError("Cannot shutdown socket as self._sock_shutdown is not set")
if self._connection is None:
raise RuntimeError(
"Cannot shutdown as connection has already been released to the pool"
)
self._sock_shutdown(socket.SHUT_RD)

def close(self) -> None:
Expand Down
16 changes: 12 additions & 4 deletions vendor/urllib3/util/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@
pass
else:
ACCEPT_ENCODING += ",br"

try:
import zstandard as _unused_module_zstd # noqa: F401
except ImportError:
pass
else:
from compression import ( # type: ignore[import-not-found] # noqa: F401
zstd as _unused_module_zstd,
)

ACCEPT_ENCODING += ",zstd"
except ImportError:
try:
import zstandard as _unused_module_zstd # noqa: F401

ACCEPT_ENCODING += ",zstd"
except ImportError:
pass


class _TYPE_FAILEDTELL(Enum):
Expand Down
Loading