mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-05 20:51:15 -07:00
* Bump requests from 2.28.2 to 2.31.0 Bumps [requests](https://github.com/psf/requests) from 2.28.2 to 2.31.0. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.28.2...v2.31.0) --- updated-dependencies: - dependency-name: requests dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update requests==2.31.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import typing
|
|
from types import TracebackType
|
|
|
|
|
|
def to_bytes(
|
|
x: str | bytes, encoding: str | None = None, errors: str | None = None
|
|
) -> bytes:
|
|
if isinstance(x, bytes):
|
|
return x
|
|
elif not isinstance(x, str):
|
|
raise TypeError(f"not expecting type {type(x).__name__}")
|
|
if encoding or errors:
|
|
return x.encode(encoding or "utf-8", errors=errors or "strict")
|
|
return x.encode()
|
|
|
|
|
|
def to_str(
|
|
x: str | bytes, encoding: str | None = None, errors: str | None = None
|
|
) -> str:
|
|
if isinstance(x, str):
|
|
return x
|
|
elif not isinstance(x, bytes):
|
|
raise TypeError(f"not expecting type {type(x).__name__}")
|
|
if encoding or errors:
|
|
return x.decode(encoding or "utf-8", errors=errors or "strict")
|
|
return x.decode()
|
|
|
|
|
|
def reraise(
|
|
tp: type[BaseException] | None,
|
|
value: BaseException,
|
|
tb: TracebackType | None = None,
|
|
) -> typing.NoReturn:
|
|
try:
|
|
if value.__traceback__ is not tb:
|
|
raise value.with_traceback(tb)
|
|
raise value
|
|
finally:
|
|
value = None # type: ignore[assignment]
|
|
tb = None
|