Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #184: loop found in loop in redundant loopback


comp / comp.lang.python / shutil.rmtree() fails when used in Fedora (rpm) "mock" environment

SubjectAuthor
* shutil.rmtree() fails when used in Fedora (rpm) "mock" environmentc.buhtz
`- Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environmentStefan Ram

1
Subject: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
From: c.buhtz@posteo.jp
Newsgroups: comp.lang.python
Date: Thu, 24 Oct 2024 07:33 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: c.buhtz@posteo.jp
Newsgroups: comp.lang.python
Subject: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
Date: Thu, 24 Oct 2024 07:33:04 +0000
Lines: 86
Message-ID: <mailman.32.1729778643.4695.python-list@python.org>
References: <4a13731716200669342338ae409e73ca@posteo.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII;
format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de DlviVJ8GWTXdpwPrxF9TkwVXXLWSFv29ozWgbPZd0NsA==
Cancel-Lock: sha1:Ug23JUYVzqcONsRLdwHTVS0L5R8= sha256:mkae8iZGHd0jYG5C1bP84FDiKMq8Rb5cRaHiaIrLgLk=
Return-Path: <c.buhtz@posteo.jp>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=posteo.jp header.i=@posteo.jp header.b=BftTNQt0;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.025
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'def': 0.04;
'subject:when': 0.07; 'fails': 0.09; 'fedora': 0.09; 'happens.':
0.09; 'skip:_ 20': 0.09; 'url-ip:140/8': 0.14; '(especially':
0.16; 'assert': 0.16; 'cleaned': 0.16; 'elements:': 0.16;
'intention': 0.16; 'path:': 0.16; 'reproduce': 0.16; 'subject:()
': 0.16; 'subject:Fedora': 0.16; 'subject:fails': 0.16;
'subject:used': 0.16; 'url-ip:140.82.121/24': 0.17; 'url-
ip:140.82/16': 0.17; 'values': 0.17; 'solve': 0.19; 'to:addr
:python-list': 0.20; 'issue': 0.21; 'maybe': 0.22; 'url:github':
0.23; 'received:de': 0.23; 'idea': 0.24; 'seems': 0.26; 'else':
0.27; 'output': 0.28; 'error': 0.29; 'packages': 0.31;
'christian': 0.32; 'path': 0.33; 'able': 0.34; "didn't": 0.34;
'item': 0.35; "we're": 0.35; 'using': 0.37; 'directory': 0.37;
'file': 0.38; 'read': 0.38; 'thanks': 0.39; 'use': 0.39; 'hello,':
0.39; 'hand': 0.40; 'four': 0.60; 'skip:o 10': 0.61; 'me.': 0.64;
'skip:t 20': 0.65; 'supply': 0.65; 'tool': 0.65; 'look': 0.65;
'[1]': 0.67; 'skip:t 30': 0.67; 'operations': 0.68; 'skip:i 40':
0.68; 'skip:/ 30': 0.69; '[2]': 0.70; 'raised': 0.70; 'note:':
0.71; 'suite': 0.71; 'received:185': 0.71; 'operate': 0.75;
'subsequent': 0.76; 'clue': 0.84; 'behind': 0.88
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.jp; s=2017;
t=1729755185; bh=/v0vtRv953lepbkUjR0+uoNjrgd3hhr4xJIPCRgKNSQ=;
h=MIME-Version:Date:From:To:Subject:Message-ID:Content-Type:
Content-Transfer-Encoding:From;
b=BftTNQt0XQ29V8boHU8YBP6UNSTN1aXkkVxhhXL+0hYvfDg/RVKU1nsiP5ozBEahJ
zvFErkimxURhJngWVGra2DT4LSX877vsHLHrAR/ZapNRxvfMs9FyOnHToPVIXr0KXH
e+bEqP/aSHbTYG87R4aKaRtWutY/cSfdzf08DQ7lDkdlvG5oGyir96Tv6usbNm2VWM
QoK51U6IocVE49kceg4iJm0smkgDa7UihkOj72fAgnLPoZIoV4jq+KYtkdThxCyMqE
gIZlw6EumejnaE6D+UD5Yq9vsu7a+/dBRLb1L8Xg3REX82zNBd+MbuvL5SAgGinY5l
sDu71QwewXILA==
X-Mailman-Approved-At: Thu, 24 Oct 2024 10:04:01 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <4a13731716200669342338ae409e73ca@posteo.de>
View all headers

Hello,
I am upstream maintainer of "Back In Time" [1] investigating an issue a
distro maintainer from Fedora reported [2] to me.

On one hand Fedora seems to use a tool called "mock" to build packages
in a chroot environment.
On the other hand the test suite of "Back In Time" does read and write
to the real file system.
One test fails because a temporary directory is cleaned up using
shutil.rmtree(). Please see the output below.

I am not familiar with Fedora and "mock". So I am not able to reproduce
this on my own.
It seems the Fedora maintainer also has no clue how to solve it or why
it happens.

Can you please have a look (especially at the line "assert func is
os.lstat").
Maybe you have an idea what is the intention behind this error raised by
an "assert" statement inside "shutil.rmtree()".

Thanks in advance,
Christian Buhtz

[1] -- <https://github.com/bit-team/backintime>
[2] -- <https://github.com/bit-team/backintime/issues/1911>

__________________________ General.test_ctor_defaults
__________________________
self = <test.test_uniquenessset.General testMethod=test_ctor_defaults>
def test_ctor_defaults(self):
"""Default values in constructor."""
> with TemporaryDirectory(prefix='bit.') as temp_name:
test/test_uniquenessset.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
/usr/lib64/python3.13/tempfile.py:946: in __exit__
self.cleanup()
/usr/lib64/python3.13/tempfile.py:950: in cleanup
self._rmtree(self.name, ignore_errors=self._ignore_cleanup_errors)
/usr/lib64/python3.13/tempfile.py:930: in _rmtree
_shutil.rmtree(name, onexc=onexc)
/usr/lib64/python3.13/shutil.py:763: in rmtree
_rmtree_safe_fd(stack, onexc)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
stack = []
onexc = <function TemporaryDirectory._rmtree.<locals>.onexc at
0xffffb39bc860>
def _rmtree_safe_fd(stack, onexc):
# Each stack item has four elements:
# * func: The first operation to perform: os.lstat, os.close or
os.rmdir.
# Walking a directory starts with an os.lstat() to detect
symlinks; in
# this case, func is updated before subsequent operations and
passed to
# onexc() if an error occurs.
# * dirfd: Open file descriptor, or None if we're processing the
top-level
# directory given to rmtree() and the user didn't supply
dir_fd.
# * path: Path of file to operate upon. This is passed to
onexc() if an
# error occurs.
# * orig_entry: os.DirEntry, or None if we're processing the
top-level
# directory given to rmtree(). We used the cached stat() of
the entry to
# save a call to os.lstat() when walking subdirectories.
func, dirfd, path, orig_entry = stack.pop()
name = path if orig_entry is None else orig_entry.name
try:
if func is os.close:
os.close(dirfd)
return
if func is os.rmdir:
os.rmdir(name, dir_fd=dirfd)
return

# Note: To guard against symlink races, we use the standard
# lstat()/open()/fstat() trick.
> assert func is os.lstat
E AssertionError
/usr/lib64/python3.13/shutil.py:663: AssertionError

Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Thu, 24 Oct 2024 14:27 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
Date: 24 Oct 2024 14:27:32 GMT
Organization: Stefan Ram
Lines: 14
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <mock-20241024151020@ram.dialup.fu-berlin.de>
References: <mailman.32.1729778643.4695.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de Aex1bwmtoK6BsbN5XQh5lAsFWHufBTNKLU/DXvL7x6EX/x
Cancel-Lock: sha1:5KWC7Rsula9GNdgoOy/5Z/otyTg= sha256:RZPBTtdFSRoBTHPLVLY0l8TLo7immQpnh8E4dvmK0vs=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

c.buhtz@posteo.jp wrote or quoted:
>Maybe you have an idea what is the intention behind this error raised by
>an "assert" statement inside "shutil.rmtree()".

Instead of banking on TemporaryDirectory's auto-cleanup, you
might wanna take a stab at nuking the directory post-test with
a more bare-bones approach like os.rmdir() or roll your own
cleanup function.

Or you could wrap the TemporaryDirectory usage in a try-except
block to catch and log any hiccups during cleanup, so the
test can keep truckin' even if that cleanup goes sideways

1

rocksolid light 0.9.8
clearnet tor