Skip to content

Commit

Permalink
Fix Page.attr: resolve before None-check (#1176)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvine committed Aug 4, 2024
1 parent d39302f commit c20cd3b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. The format

- Fix error on getting `.annots`/`.hyperlinks` from `CroppedPage` (due to missing `.rotation` and `.initial_doctop` attributes) (h/t @Safrone). ([#1171](https://github.com/jsvine/pdfplumber/issues/1171) + [e5737d2](https://github.com/jsvine/pdfplumber/commit/e5737d2))
- Dereference structure element attributes (h/t @dhdaines). ([#1169](https://github.com/jsvine/pdfplumber/pull/1169))
- Fix `Page.get_attr(...)` so that it fully resolves references before determining whether the attribute's value is `None` (h/t @zzhangyun + @mkl). ([#1176](https://github.com/jsvine/pdfplumber/issues/1176))

## [0.11.2] - 2024-07-06

Expand Down
4 changes: 2 additions & 2 deletions pdfplumber/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def __init__(
self.initial_doctop = initial_doctop

def get_attr(key: str, default: Any = None) -> Any:
ref = page_obj.attrs.get(key)
return default if ref is None else resolve_all(ref)
value = resolve_all(page_obj.attrs.get(key))
return default if value is None else value

# Per PDF Reference Table 3.27: "The number of degrees by which the
# page should be rotated clockwise when displayed or printed. The value
Expand Down

0 comments on commit c20cd3b

Please sign in to comment.