Skip to content

Commit 2c53af9

Browse files
committed
Windows: avoid unecessary class attributes
1 parent c95dd97 commit 2c53af9

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ History:
55
4.0.0 201x/xx/xx
66
- MSS: renamed MSSBase to MSSMixin in base.py
77
- Linux: ensure resources are freed in grab()
8+
- Windows: avoid unecessary class attributes
89
- MSS: fix Flake8 C408: Unnecessary dict call - rewrite as a literal, in exceptions.py
910
- MSS: fix Flake8 I100: Import statements are in the wrong order
1011
- MSS: fix Flake8 I201: Missing newline before sections or imports

mss/windows.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,15 @@ class BITMAPINFO(ctypes.Structure):
5252
class MSS(MSSMixin):
5353
""" Multiple ScreenShots implementation for Microsoft Windows. """
5454

55-
_bbox = {"height": 0, "width": 0}
56-
_bmp = None
57-
_data = None
58-
_memdc = None
59-
_srcdc = None
60-
6155
def __init__(self):
6256
# type: () -> None
6357
""" Windows initialisations. """
6458

6559
self._monitors = [] # type: List[Dict[str, int]]
6660

61+
self._bbox = {"height": 0, "width": 0}
62+
self._bmp = None
63+
6764
self.monitorenumproc = ctypes.WINFUNCTYPE(
6865
ctypes.wintypes.INT,
6966
ctypes.wintypes.DWORD,
@@ -100,7 +97,8 @@ def __exit__(self, *args):
10097
# type: (*str) -> None
10198
""" Cleanup. """
10299

103-
for attr in (self._bmp, self._memdc, self._srcdc):
100+
for attribute in {"_bmp", "_memdc", "_srcdc"}:
101+
attr = getattr(self, attribute, None)
104102
if attr:
105103
ctypes.windll.gdi32.DeleteObject(attr)
106104

0 commit comments

Comments
 (0)