Skip to content

Commit

Permalink
FIXES: #2961
Browse files Browse the repository at this point in the history
  • Loading branch information
bwagner committed Jan 3, 2024
1 parent 40014c7 commit b1c5b44
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2546,7 +2546,7 @@ def __exit__(self, *args):
self.close()

def __getitem__(self, i: int =0):
assert isinstance(i, int)
assert isinstance(i, int) or (isinstance(i, tuple) and len(i) == 2 and all(isinstance(x, int) for x in i))
if i not in self:
raise IndexError(f"page {i} not in document")
return self.load_page(i)
Expand Down
2 changes: 1 addition & 1 deletion src_classic/fitz_old.i
Original file line number Diff line number Diff line change
Expand Up @@ -4800,7 +4800,7 @@ if basestate:


def __getitem__(self, i: int =0)->"Page":
assert isinstance(i, int)
assert isinstance(i, int) or (isinstance(i, tuple) and len(i) == 2 and all(isinstance(x, int) for x in i))
if i not in self:
raise IndexError("page not in document")
return self.load_page(i)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pixmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ def test_page_idx_int():
doc = fitz.open(pdf)
with pytest.raises(AssertionError):
doc["0"]
assert doc[0]
assert doc[(0,0)]

0 comments on commit b1c5b44

Please sign in to comment.