Browse Source

tests: do not leak open file

Marek Marczykowski-Górecki 6 years ago
parent
commit
241f1d1d3b
1 changed files with 2 additions and 1 deletions
  1. 2 1
      qubes/ext/pci.py

+ 2 - 1
qubes/ext/pci.py

@@ -71,7 +71,8 @@ def pcidev_class(dev_xmldesc):
     sysfs_path = dev_xmldesc.findtext('path')
     assert sysfs_path
     try:
-        class_id = open(sysfs_path + '/class').read().strip()
+        with open(sysfs_path + '/class') as f_class:
+            class_id = f_class.read().strip()
     except OSError:
         return "Unknown"