@@ -276,10 +276,11 @@ def test_embeddable(self) -> None:
276
276
except Exception :
277
277
pytest .skip ("Compiler could not be initialized" )
278
278
279
- with open ("embed_pil.c" , "w" , encoding = "utf-8" ) as fh :
280
- home = sys .prefix .replace ("\\ " , "\\ \\ " )
281
- fh .write (
282
- f"""
279
+ try :
280
+ with open ("embed_pil.c" , "w" , encoding = "utf-8" ) as fh :
281
+ home = sys .prefix .replace ("\\ " , "\\ \\ " )
282
+ fh .write (
283
+ f"""
283
284
#include "Python.h"
284
285
285
286
int main(int argc, char* argv[])
@@ -301,17 +302,19 @@ def test_embeddable(self) -> None:
301
302
return 0;
302
303
}}
303
304
"""
304
- )
305
+ )
305
306
306
- objects = compiler .compile (["embed_pil.c" ])
307
- compiler .link_executable (objects , "embed_pil" )
307
+ objects = compiler .compile (["embed_pil.c" ])
308
+ compiler .link_executable (objects , "embed_pil" )
308
309
309
- env = os .environ .copy ()
310
- env ["PATH" ] = sys .prefix + ";" + env ["PATH" ]
310
+ env = os .environ .copy ()
311
+ env ["PATH" ] = sys .prefix + ";" + env ["PATH" ]
311
312
312
- # Do not display the Windows Error Reporting dialog
313
- getattr (ctypes , "windll" ).kernel32 .SetErrorMode (0x0002 )
313
+ # Do not display the Windows Error Reporting dialog
314
+ getattr (ctypes , "windll" ).kernel32 .SetErrorMode (0x0002 )
314
315
315
- process = subprocess .Popen (["embed_pil.exe" ], env = env )
316
- process .communicate ()
317
- assert process .returncode == 0
316
+ process = subprocess .Popen (["embed_pil.exe" ], env = env )
317
+ process .communicate ()
318
+ assert process .returncode == 0
319
+ finally :
320
+ os .remove ("embed_pil.c" )
0 commit comments