@@ -276,12 +276,24 @@ def _waitfor(func, pathname, waitall=False):
276
276
RuntimeWarning , stacklevel = 4 )
277
277
278
278
def _unlink (filename ):
279
+ # XXX RUSTPYTHON: on ci, unlink() raises PermissionError when target doesn't exist.
280
+ # Might also happen locally, but not sure
281
+ if not os .path .exists (filename ):
282
+ return
279
283
_waitfor (os .unlink , filename )
280
284
281
285
def _rmdir (dirname ):
286
+ # XXX RUSTPYTHON: on ci, rmdir() raises PermissionError when target doesn't exist.
287
+ # Might also happen locally, but not sure
288
+ if not os .path .exists (dirname ):
289
+ return
282
290
_waitfor (os .rmdir , dirname )
283
291
284
292
def _rmtree (path ):
293
+ # XXX RUSTPYTHON: on ci, rmdir() raises PermissionError when target doesn't exist.
294
+ # Might also happen locally, but not sure
295
+ if not os .path .exists (path ):
296
+ return
285
297
from test .support import _force_run
286
298
287
299
def _rmtree_inner (path ):
@@ -399,7 +411,18 @@ def temp_dir(path=None, quiet=False):
399
411
# In case the process forks, let only the parent remove the
400
412
# directory. The child has a different process id. (bpo-30028)
401
413
if dir_created and pid == os .getpid ():
402
- rmtree (path )
414
+ try :
415
+ rmtree (path )
416
+ except OSError as exc :
417
+ # XXX RUSTPYTHON: something something async file removal?
418
+ # also part of the thing with rmtree()
419
+ # throwing PermissionError, I think
420
+ if os .path .exists (path ):
421
+ if not quiet :
422
+ raise
423
+ warnings .warn (f'unable to remove temporary'
424
+ f'directory { path !r} : { exc } ' ,
425
+ RuntimeWarning , stacklevel = 3 )
403
426
404
427
405
428
@contextlib .contextmanager
0 commit comments