Commits

Philip Jenvey  committed b2c5513

close it in _ctypes_test too

  • Participants
  • Parent commits 308ded0

Comments (0)

Files changed (2)

File lib_pypy/_ctypes_test.py

-import imp, os
+import imp
+import os
 
 try:
     import cpyext
     output_dir = _pypy_testcapi.get_hashed_dir(os.path.join(thisdir, cfile))
     try:
         fp, filename, description = imp.find_module('_ctypes_test', path=[output_dir])
-        imp.load_module('_ctypes_test', fp, filename, description)
+        with fp:
+            imp.load_module('_ctypes_test', fp, filename, description)
     except ImportError:
         print('could not find _ctypes_test in %s' % output_dir)
         _pypy_testcapi.compile_shared('_ctypes_test.c', '_ctypes_test', output_dir)

File lib_pypy/_testcapi.py

 
 try:
     fp, filename, description = imp.find_module('_testcapi', path=[output_dir])
-    try:
+    with fp:
         imp.load_module('_testcapi', fp, filename, description)
-    finally:
-        fp.close()
 except ImportError:
     _pypy_testcapi.compile_shared(cfile, '_testcapi', output_dir)