Skip to content

Commit e2f1b67

Browse files
committed
Fixed an issue where __init__.check_dt_compatible_value opened a file but did not close it and thus caused a memory leak and a ResourceWarning.
1 parent 1b43d2a commit e2f1b67

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

adafruit_platformdetect/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ def check_dt_compatible_value(self, value):
6262
"""
6363
# Match a value like 'qcom,apq8016-sbc':
6464
try:
65-
if value in open("/proc/device-tree/compatible").read():
66-
return True
65+
with open("/proc/device-tree/compatible") as compatible:
66+
if value in compatible.read():
67+
return True
6768
except FileNotFoundError:
6869
pass
6970

0 commit comments

Comments
 (0)