Skip to content

Commit

Permalink
DEP: Amend decode_permissions (#2953)
Browse files Browse the repository at this point in the history
This was deprecated with replacement user_access_permissions. Removal was scheduled for version 5.0.0 or later.

Change decode_permissions from deprecate_with_replacement to deprecation_with_replacement.
  • Loading branch information
j-t-1 authored Nov 19, 2024
1 parent ad5f3ef commit 92bb037
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pypdf/_doc_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from ._page import PageObject, _VirtualList
from ._page_labels import index2label as page_index2page_label
from ._utils import (
deprecate_with_replacement,
deprecation_with_replacement,
logger_warning,
parse_iso8824_date,
)
Expand Down Expand Up @@ -1281,10 +1281,10 @@ def decode_permissions(
self, permissions_code: int
) -> Dict[str, bool]: # pragma: no cover
"""Take the permissions as an integer, return the allowed access."""
deprecate_with_replacement(
deprecation_with_replacement(
old_name="decode_permissions",
new_name="user_access_permissions",
removed_in="5.0.0",
removed_in="6.0.0",
)

permissions_mapping = {
Expand Down
9 changes: 5 additions & 4 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pypdf.constants import PageAttributes as PG
from pypdf.constants import UserAccessPermissions as UAP
from pypdf.errors import (
DeprecationError,
EmptyFileError,
FileNotDecryptedError,
PdfReadError,
Expand Down Expand Up @@ -745,16 +746,16 @@ def test_decode_permissions():
print_ = base.copy()
print_["print"] = True
with pytest.raises(
DeprecationWarning,
match="decode_permissions is deprecated and will be removed in pypdf 5.0.0. Use user_access_permissions instead", # noqa: E501
DeprecationError,
match="decode_permissions is deprecated and was removed in pypdf 6.0.0. Use user_access_permissions instead",
):
assert reader.decode_permissions(4) == print_

modify = base.copy()
modify["modify"] = True
with pytest.raises(
DeprecationWarning,
match="decode_permissions is deprecated and will be removed in pypdf 5.0.0. Use user_access_permissions instead", # noqa: E501
DeprecationError,
match="decode_permissions is deprecated and was removed in pypdf 6.0.0. Use user_access_permissions instead",
):
assert reader.decode_permissions(8) == modify

Expand Down

0 comments on commit 92bb037

Please sign in to comment.