Skip to content

Commit 2d2ee96

Browse files
authored
Merge pull request #162 from bgilbert/3.6
Drop Python 3.6 support
2 parents e90c5c7 + 77eea61 commit 2d2ee96

File tree

8 files changed

+13
-44
lines changed

8 files changed

+13
-44
lines changed

.github/workflows/python.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
matrix:
3030
os: [ubuntu-latest, macos-latest]
31-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
31+
python-version: [3.7, 3.8, 3.9, "3.10"]
3232
steps:
3333
- name: Check out repo
3434
uses: actions/checkout@v2
@@ -71,7 +71,7 @@ jobs:
7171
shell: bash
7272
strategy:
7373
matrix:
74-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
74+
python-version: [3.7, 3.8, 3.9, "3.10"]
7575
python-arch: [x86, x64]
7676
steps:
7777
- name: Check out repo

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repos:
1818
hooks:
1919
- id: pyupgrade
2020
name: Modernize python code
21-
args: ["--py36-plus"]
21+
args: ["--py37-plus"]
2222

2323
- repo: https://github.com/PyCQA/isort
2424
rev: 5.8.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ OpenSlide can read virtual slides in several formats:
3737

3838
## Requirements
3939

40-
* Python ≥ 3.6
40+
* Python ≥ 3.7
4141
* OpenSlide ≥ 3.4.0
4242
* Pillow
4343

openslide/__init__.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,21 +331,15 @@ def detect_format(cls, filename):
331331
332332
If the file format is not recognized, return None."""
333333
try:
334-
img = Image.open(filename)
335-
format = img.format
336-
if hasattr(img, 'close'):
337-
# Pillow >= 2.5.0
338-
img.close()
339-
return format
334+
with Image.open(filename) as img:
335+
return img.format
340336
except OSError:
341337
return None
342338

343339
def close(self):
344340
"""Close the slide object."""
345341
if self._close:
346-
if hasattr(self._image, 'close'):
347-
# Pillow >= 2.5.0
348-
self._image.close()
342+
self._image.close()
349343
self._close = False
350344
self._image = None
351345

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@
3939
'Operating System :: POSIX :: Linux',
4040
'Programming Language :: Python',
4141
'Programming Language :: Python :: 3',
42-
'Programming Language :: Python :: 3.6',
4342
'Programming Language :: Python :: 3.7',
4443
'Programming Language :: Python :: 3.8',
4544
'Programming Language :: Python :: 3.9',
4645
'Programming Language :: Python :: 3.10',
4746
'Topic :: Scientific/Engineering :: Bio-Informatics',
4847
],
49-
python_requires='>=3.6',
48+
python_requires='>=3.7',
5049
install_requires=[
5150
'Pillow',
5251
],

tests/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import os
2222
from pathlib import Path
2323

24-
from PIL import Image
25-
2624
# Handle Windows-specific first-import logic here, so individual modules
2725
# don't have to
2826
if os.name == 'nt':
@@ -45,14 +43,6 @@
4543

4644
from openslide import OpenSlideVersionError
4745

48-
# PIL.Image cannot have zero width or height on Pillow 3.4.0 - 3.4.2
49-
# https://github.com/python-pillow/Pillow/issues/2259
50-
try:
51-
Image.new('RGBA', (1, 0))
52-
image_dimensions_cannot_be_zero = False
53-
except ValueError:
54-
image_dimensions_cannot_be_zero = True
55-
5646

5747
def file_path(name):
5848
return Path(__file__).parent / name

tests/test_imageslide.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,13 @@
1717
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1818
#
1919

20-
from contextlib import contextmanager
2120
import unittest
2221

2322
from PIL import Image
2423

2524
from openslide import ImageSlide, OpenSlideCache, OpenSlideError
2625

27-
from . import file_path, image_dimensions_cannot_be_zero, maybe_supported
28-
29-
30-
@contextmanager
31-
def image_open(*args, **kwargs):
32-
img = Image.open(*args, **kwargs)
33-
try:
34-
yield img
35-
finally:
36-
if hasattr(img, 'close'):
37-
# Pillow >= 2.5.0
38-
img.close()
26+
from . import file_path, maybe_supported
3927

4028

4129
class TestImageWithoutOpening(unittest.TestCase):
@@ -50,13 +38,13 @@ def test_open(self):
5038

5139
def test_open_image(self):
5240
# passing PIL.Image to ImageSlide
53-
with image_open(file_path('boxes.png')) as img:
41+
with Image.open(file_path('boxes.png')) as img:
5442
with ImageSlide(img) as osr:
5543
self.assertEqual(osr.dimensions, (300, 250))
5644
self.assertEqual(repr(osr), 'ImageSlide(%r)' % img)
5745

5846
def test_operations_on_closed_handle(self):
59-
with image_open(file_path('boxes.png')) as img:
47+
with Image.open(file_path('boxes.png')) as img:
6048
osr = ImageSlide(img)
6149
osr.close()
6250
self.assertRaises(
@@ -102,7 +90,6 @@ def test_read_region(self):
10290
self.osr.read_region((-10, -10), 0, (400, 400)).size, (400, 400)
10391
)
10492

105-
@unittest.skipIf(image_dimensions_cannot_be_zero, 'Pillow issue #2259')
10693
def test_read_region_size_dimension_zero(self):
10794
self.assertEqual(self.osr.read_region((0, 0), 0, (400, 0)).size, (400, 0))
10895

tests/test_openslide.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
OpenSlideUnsupportedFormatError,
3232
)
3333

34-
from . import file_path, image_dimensions_cannot_be_zero, maybe_supported
34+
from . import file_path, maybe_supported
3535

3636

3737
class TestCache(unittest.TestCase):
@@ -128,7 +128,6 @@ def test_read_region(self):
128128
self.osr.read_region((-10, -10), 1, (400, 400)).size, (400, 400)
129129
)
130130

131-
@unittest.skipIf(image_dimensions_cannot_be_zero, 'Pillow issue #2259')
132131
def test_read_region_size_dimension_zero(self):
133132
self.assertEqual(self.osr.read_region((0, 0), 1, (400, 0)).size, (400, 0))
134133

@@ -141,7 +140,7 @@ def test_read_region_bad_size(self):
141140
)
142141

143142
@unittest.skipIf(sys.maxsize < 1 << 32, '32-bit Python')
144-
# Broken on Pillow >= 3.4.0, < 6.2.0.
143+
# Broken on Pillow < 6.2.0.
145144
# https://github.com/python-pillow/Pillow/issues/3963
146145
@unittest.skipIf(
147146
[int(i) for i in getattr(Image, '__version__', '0').split('.')] < [6, 2, 0],

0 commit comments

Comments
 (0)