Skip to content

Commit b1c5b44

Browse files
committed
FIXES: #2961
1 parent 40014c7 commit b1c5b44

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,7 @@ def __exit__(self, *args):
25462546
self.close()
25472547

25482548
def __getitem__(self, i: int =0):
2549-
assert isinstance(i, int)
2549+
assert isinstance(i, int) or (isinstance(i, tuple) and len(i) == 2 and all(isinstance(x, int) for x in i))
25502550
if i not in self:
25512551
raise IndexError(f"page {i} not in document")
25522552
return self.load_page(i)

src_classic/fitz_old.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4800,7 +4800,7 @@ if basestate:
48004800

48014801

48024802
def __getitem__(self, i: int =0)->"Page":
4803-
assert isinstance(i, int)
4803+
assert isinstance(i, int) or (isinstance(i, tuple) and len(i) == 2 and all(isinstance(x, int) for x in i))
48044804
if i not in self:
48054805
raise IndexError("page not in document")
48064806
return self.load_page(i)

tests/test_pixmap.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,6 @@ def test_page_idx_int():
137137
doc = fitz.open(pdf)
138138
with pytest.raises(AssertionError):
139139
doc["0"]
140+
assert doc[0]
141+
assert doc[(0,0)]
140142

0 commit comments

Comments
 (0)