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

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



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


Commits:
274f7938 by Krzysztof Gogolewski at 2023-01-11T20:49:14+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 io.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/274f7938b94c43dcb5b5947e5a7c74a749fc2c70

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/274f7938b94c43dcb5b5947e5a7c74a749fc2c70
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/9e69aecf/attachment-0001.html>


More information about the ghc-commits mailing list