mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-04 20:03:20 +03:00
Allow for custom stacklevel in deprecations
This commit is contained in:
parent
d23d56e195
commit
79e0b0b6ad
|
@ -1370,7 +1370,7 @@ def _save(
|
||||||
msg = f"cannot write mode {mode} as PNG"
|
msg = f"cannot write mode {mode} as PNG"
|
||||||
raise OSError(msg) from e
|
raise OSError(msg) from e
|
||||||
if outmode == "I":
|
if outmode == "I":
|
||||||
deprecate("Saving I mode images as PNG", 13)
|
deprecate("Saving I mode images as PNG", 13, stacklevel=4)
|
||||||
|
|
||||||
#
|
#
|
||||||
# write minimal PNG file
|
# write minimal PNG file
|
||||||
|
|
|
@ -12,6 +12,7 @@ def deprecate(
|
||||||
*,
|
*,
|
||||||
action: str | None = None,
|
action: str | None = None,
|
||||||
plural: bool = False,
|
plural: bool = False,
|
||||||
|
stacklevel: int = 3,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Deprecations helper.
|
Deprecations helper.
|
||||||
|
@ -67,5 +68,5 @@ def deprecate(
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
f"{deprecated} {is_} deprecated and will be removed in {removed}{action}",
|
f"{deprecated} {is_} deprecated and will be removed in {removed}{action}",
|
||||||
DeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=3,
|
stacklevel=stacklevel,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user