[Git][ghc/ghc][wip/python-files] Fix unclosed files in Python testdriver

Krzysztof Gogolewski (@monoidal) gitlab at gitlab.haskell.org
Wed Jan 11 19:31:31 UTC 2023



Krzysztof Gogolewski pushed to branch wip/python-files at Glasgow Haskell Compiler / GHC


Commits:
1474b862 by Krzysztof Gogolewski at 2023-01-11T20:31:13+01:00
Fix unclosed files in Python testdriver

- - - - -


2 changed files:

- testsuite/driver/cpu_features.py
- testsuite/driver/runtests.py


Changes:

=====================================
testsuite/driver/cpu_features.py
=====================================
@@ -17,7 +17,8 @@ cpu_feature_cache = None
 
 def get_cpu_features():
     if config.os in ['mingw32', 'linux'] and os.path.exists('/proc/cpuinfo'):
-        f = open('/proc/cpuinfo').read()
+        with open('/proc/cpuinfo') as x:
+            f = x.read()
         flags = re.search(r'flags\s*:\s*.*$', f, re.M)
         if flags is None:
             print('get_cpu_features: failed to find cpu features')


=====================================
testsuite/driver/runtests.py
=====================================
@@ -99,7 +99,8 @@ if args.e:
 
 if args.config_file:
     for arg in args.config_file:
-        exec(open(arg).read())
+        with open(arg) as f:
+            exec(f.read())
 
 if args.config:
     for arg in args.config:



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1474b8629c8ab1f3452342f5c8dfb037f4230e96

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1474b8629c8ab1f3452342f5c8dfb037f4230e96
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230111/1e79a6eb/attachment-0001.html>


More information about the ghc-commits mailing list