Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #23: improperly oriented keyboard


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

SubjectAuthor
o Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environmentMRAB

1
Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
From: MRAB
Newsgroups: comp.lang.python
Date: Thu, 24 Oct 2024 15:44 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: python@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
Date: Thu, 24 Oct 2024 16:44:30 +0100
Lines: 121
Message-ID: <mailman.35.1729784858.4695.python-list@python.org>
References: <4a13731716200669342338ae409e73ca@posteo.de>
<CAJQBtg=kCr0VMGXvkBcj4U6CwatC2_G2dstO5pS56_koAXJurA@mail.gmail.com>
<0c080a7d-92de-4518-ac44-78d97fc9e3bb@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de zDfBjsZX8WFeH1NAHayA4w2hg8wSdDZHaVU6oGwwkkWQ==
Cancel-Lock: sha1:uU3AENV3PYre5lWNg4Jyj9MfZe0= sha256:jDVZU46fohpvzsKoEmpbMwzNcdPaRENLk2WQ6BVCxmw=
Return-Path: <python@mrabarnett.plus.com>
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=plus.com header.i=@plus.com header.b=eGhjUnhm;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04;
'subject:when': 0.07; 'url:mailman': 0.09; 'environments': 0.09;
'fails': 0.09; 'fedora': 0.09; 'from:addr:python': 0.09;
'happens.': 0.09; 'identical': 0.09; 'like,': 0.09; 'python)':
0.09; 'received:192.168.1.64': 0.09; 'skip:_ 20': 0.09; 'url-
ip:140/8': 0.14; 'memory': 0.15; 'url:listinfo': 0.15;
'(especially': 0.16; '(more': 0.16; '651': 0.16; '677': 0.16;
'679': 0.16; '689': 0.16; '760': 0.16; 'addresses.': 0.16;
'appended': 0.16; 'assert': 0.16; 'cases,': 0.16; 'cleaned': 0.16;
'elements:': 0.16; 'from:addr:mrabarnett.plus.com': 0.16;
'from:name:mrab': 0.16; 'functions.': 0.16; 'intention': 0.16;
"isn't,": 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'path:':
0.16; 'received:plus.net': 0.16; 'reproduce': 0.16; 'subject:() ':
0.16; 'subject:Fedora': 0.16; 'subject:fails': 0.16;
'subject:used': 0.16; 'tuples': 0.16; 'wrote:': 0.16; 'problem':
0.16; 'python': 0.16; 'url-ip:140.82.121/24': 0.17; 'url-
ip:140.82/16': 0.17; 'values': 0.17; "can't": 0.17; 'solve': 0.19;
'thu,': 0.19; 'to:addr:python-list': 0.20; 'url-
ip:188.166.95.178/32': 0.20; 'url-ip:188.166.95/24': 0.20;
'issue': 0.21; 'exception': 0.22; 'i.e.': 0.22; 'maybe': 0.22;
'lines': 0.23; 'url:github': 0.23; 'code': 0.23; 'list,': 0.24;
'url-ip:188.166/16': 0.24; "i'd": 0.24; 'idea': 0.24; 'actual':
0.25; 'seems': 0.26; "isn't": 0.27; 'else': 0.27; 'coming': 0.27;
'function': 0.27; 'output': 0.28; 'error': 0.29; 'header:User-
Agent:1': 0.30; 'packages': 0.31; 'module': 0.31; 'checks': 0.32;
'christian': 0.32; 'elements': 0.32; 'from,': 0.32; 'guess': 0.32;
'performed': 0.32; 'python-list': 0.32; 'but': 0.32;
'received:192.168.1': 0.32; "i'm": 0.33; 'there': 0.33; 'path':
0.33; 'header:In-Reply-To:1': 0.34; 'able': 0.34; "didn't": 0.34;
'item': 0.35; 'following': 0.35; "we're": 0.35; 'those': 0.36;
'using': 0.37; "it's": 0.37; 'could': 0.37; 'directory': 0.37;
'received:192.168': 0.37; 'file': 0.38; 'put': 0.38; 'read': 0.38;
'both': 0.38; 'list': 0.39; 'thanks': 0.39; 'use': 0.39; 'hello,':
0.39; "that's": 0.39; 'this,': 0.39; 'edit': 0.39; 'hand': 0.40;
'something': 0.40; 'four': 0.60; 'skip:o 10': 0.61; "there's":
0.61; 'between': 0.63; '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;
'right': 0.68; 'operations': 0.68; 'skip:i 40': 0.68; 'skip:/ 30':
0.69; '[2]': 0.70; 'raised': 0.70; 'note:': 0.71; 'suite': 0.71;
'operate': 0.75; 'subsequent': 0.76; 'left': 0.83; 'known': 0.84;
'clue': 0.84; 'stack,': 0.84; 'behind': 0.88
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1729784671; bh=4vI6IKJzbbn4wUDBsy0xHxzOBu2VIbouA/Qg/Xcxbf0=;
h=Date:Subject:To:References:From:In-Reply-To;
b=eGhjUnhmgdVjWXXxpa6ICAxunUfgyD8KT6T9knS+aGz0K2JhIjUA+jWo+XfRLB+Bo
ZBPSsE2q1Ttdun1dJFbhPM2oEquIVUFulxMsXH9C0rh3OCzBp6j69a3sNqK6rZaOfI
9CGj1x6oB8bnTHkvHTpZbF74J3uZTbZnTz1URd93132Uo+7jN4BrG9gODeKy2Of45i
jyEEJ17+tIiRZyudA4t7nYeFopcvvHcvl4kPFqHp12YYAOpFNh2PA8cNCVU2M9z7q/
6BxonYTg1RomQWr/7d8J0xWGPEodfWnkrw1RxMv3AFoY98vD+spWBh0lvlVP93NtNo
p4rXzLaemYWyA==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=GMarEfNK c=1 sm=1 tr=0 ts=671a6b5f
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=8AHkEIZyAAAA:8 a=NEAV23lmAAAA:8 a=tiBpBG2MrMJqL05IBnEA:9
a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <CAJQBtg=kCr0VMGXvkBcj4U6CwatC2_G2dstO5pS56_koAXJurA@mail.gmail.com>
X-CMAE-Envelope: MS4xfNaEyN9iWKM9zir8Y0LjbxYFGak3fJ3VhhA2LJcTKAcDpAMHfgKkzdQAullOplAMjbbr2vo7vrT3cxJ3pn4YehKBBeBv4Zhb/sBAygxscTrNSKIdr1XZ
4zLUvanx4mLbztAs/OcSl+ewK1uPrTJbyYs1DNU5/mxWdI890z/Op+x2/lJRBKlVCJyaszazpYP8d6P8NeVIJBwvru6kNmfuCtE=
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: <0c080a7d-92de-4518-ac44-78d97fc9e3bb@mrabarnett.plus.com>
X-Mailman-Original-References: <4a13731716200669342338ae409e73ca@posteo.de>
<CAJQBtg=kCr0VMGXvkBcj4U6CwatC2_G2dstO5pS56_koAXJurA@mail.gmail.com>
View all headers

On 2024-10-24 16:17, Left Right via Python-list wrote:
> From reading the code where the exception is coming from, this is how
> I interpret the intention of the author: they build a list (not sure
> why they used list, when there's a stack datastructure in Python)
> which they use as a stack, where the elements of the stack are
> 4-tuples, the important part about these tuples is that the first
> element is the operation to be performed by rmtree() has to be one of
> the known filesystem-related functions. The code raising the exception
> checks that it's one of those kinds and if it isn't, crashes.
>
> There is, however, a problem with testing equality (more strictly,
> identity in this case) between functions. I.e. it's possible that a
> function isn't identical to itself is, eg. "os" module was somehow
> loaded twice. I'm not sure if that's a real possibility with how
> Python works... but maybe in some cases, like, multithreaded
> environments it could happen...
>
> To investigate this, I'd edit the file with the assertion and make it
> print the actual value found in os.lstat and func. My guess is that
> they are both somehow "lstat", but with different memory addresses.
>
The stack is created on line 760 with os.lstat and entries are appended
on lines 677 (os.rmdir), 679 (os.close) and 689 (os.lstat).

'func' is popped off the stack on line 651 and check in the following lines.

I can't see anywhere else where something else is put onto the stack or
an entry is replaced.

> On Thu, Oct 24, 2024 at 4:06 PM Christian Buhtz via Python-list
> <python-list@python.org> wrote:
>>
>> 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
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list

1

rocksolid light 0.9.8
clearnet tor