Skip to content

Commit 97607cf

Browse files
committed
Fix openslide.open_slide() suboptimalities
open_slide() was calling can_open() before opening the slide, exactly as the documentation says not to. After failing to open a slide, it was swallowing the error.
1 parent 559a145 commit 97607cf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

openslide/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ def open_slide(filename):
352352
353353
Return an OpenSlide object for whole-slide images and an ImageSlide
354354
object for other types of images."""
355-
if OpenSlide.can_open(filename):
355+
try:
356356
return OpenSlide(filename)
357-
else:
357+
except OpenSlideUnsupportedFormatError:
358358
return ImageSlide(filename)
359359

360360

0 commit comments

Comments
 (0)