Skip to content

Commit be3f341

Browse files
committed
os_helper: add XXX RUSTPYTHON back
1 parent 20cef39 commit be3f341

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Lib/test/support/os_helper.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,24 @@ def _waitfor(func, pathname, waitall=False):
276276
RuntimeWarning, stacklevel=4)
277277

278278
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
279283
_waitfor(os.unlink, filename)
280284

281285
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
282290
_waitfor(os.rmdir, dirname)
283291

284292
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
285297
from test.support import _force_run
286298

287299
def _rmtree_inner(path):
@@ -399,7 +411,18 @@ def temp_dir(path=None, quiet=False):
399411
# In case the process forks, let only the parent remove the
400412
# directory. The child has a different process id. (bpo-30028)
401413
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)
403426

404427

405428
@contextlib.contextmanager

0 commit comments

Comments
 (0)