Open
Description
________________________ TestLocalPath.test_chdir_gone _________________________
self = <module 'py.error'>, func = <function rmtree at 0x7fffaea92af0>
args = ('/tmp/pytest-of-marcel/pytest-43/path1/dir_to_be_removed',)
kwargs = {'ignore_errors': False}, __tracebackhide__ = False
cls = <class 'py.error.EINVAL'>, value = OSError(22, 'Invalid argument')
tb = <traceback object at 0x7fffa9e9f3c0>, errno = 22
def checked_call(self, func, *args, **kwargs):
""" call a function and raise an errno-exception if applicable. """
__tracebackhide__ = True
try:
> return func(*args, **kwargs)
/usr/lib/python3.9/vendor-packages/py/_error.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.9/shutil.py:740: in rmtree
onerror(os.rmdir, path, sys.exc_info())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path = '/tmp/pytest-of-marcel/pytest-43/path1/dir_to_be_removed'
ignore_errors = False
onerror = <function rmtree.<locals>.onerror at 0x7fffa94e2f70>
def rmtree(path, ignore_errors=False, onerror=None):
"""Recursively delete a directory tree.
If ignore_errors is set, errors are ignored; otherwise, if onerror
is set, it is called to handle the error with arguments (func,
path, exc_info) where func is platform and implementation dependent;
path is the argument to that function that caused it to fail; and
exc_info is a tuple returned by sys.exc_info(). If ignore_errors
is false and onerror is None, an exception is raised.
"""
sys.audit("shutil.rmtree", path)
if ignore_errors:
def onerror(*args):
pass
elif onerror is None:
def onerror(*args):
raise
if _use_fd_functions:
# While the unsafe rmtree works fine on bytes, the fd based does not.
if isinstance(path, bytes):
path = os.fsdecode(path)
# Note: To guard against symlink races, we use the standard
# lstat()/open()/fstat() trick.
try:
orig_st = os.lstat(path)
except Exception:
onerror(os.lstat, path, sys.exc_info())
return
try:
fd = os.open(path, os.O_RDONLY)
fd_closed = False
except Exception:
onerror(os.open, path, sys.exc_info())
return
try:
if os.path.samestat(orig_st, os.fstat(fd)):
_rmtree_safe_fd(fd, path, onerror)
try:
os.close(fd)
fd_closed = True
> os.rmdir(path)
E OSError: [Errno 22] Invalid argument: '/tmp/pytest-of-marcel/pytest-43/path1/dir_to_be_removed'
/usr/lib/python3.9/shutil.py:738: OSError
During handling of the above exception, another exception occurred:
self = <test_local.TestLocalPath object at 0x7fffaa830520>
path1 = local('/tmp/pytest-of-marcel/pytest-43/path1')
@skiponwin32
def test_chdir_gone(self, path1):
p = path1.ensure("dir_to_be_removed", dir=1)
p.chdir()
> p.remove()
$(BUILD_DIR)/testing/_py/test_local.py:623:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.9/vendor-packages/py/_path/local.py:218: in remove
py.error.checked_call(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <module 'py.error'>, func = <function rmtree at 0x7fffaea92af0>
args = ('/tmp/pytest-of-marcel/pytest-43/path1/dir_to_be_removed',)
kwargs = {'ignore_errors': False}, __tracebackhide__ = False
cls = <class 'py.error.EINVAL'>, value = OSError(22, 'Invalid argument')
tb = <traceback object at 0x7fffa9e9f3c0>, errno = 22
def checked_call(self, func, *args, **kwargs):
""" call a function and raise an errno-exception if applicable. """
__tracebackhide__ = True
try:
return func(*args, **kwargs)
except self.Error:
raise
except (OSError, EnvironmentError):
cls, value, tb = sys.exc_info()
if not hasattr(value, 'errno'):
raise
__tracebackhide__ = False
errno = value.errno
try:
if not isinstance(value, WindowsError):
raise NameError
except NameError:
# we are not on Windows, or we got a proper OSError
cls = self._geterrnoclass(errno)
else:
try:
cls = self._geterrnoclass(_winerrnomap[errno])
except KeyError:
raise value
> raise cls("%s%r" % (func.__name__, args))
E py.error.EINVAL: [Invalid argument]: rmtree('/tmp/pytest-of-marcel/pytest-43/path1/dir_to_be_removed',)
/usr/lib/python3.9/vendor-packages/py/_error.py:86: EINVAL
This sounds similar to stanislavlevin/pyproject_installer#33 and Bachmann1234/diff_cover#308.