Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <mailman.33.1729781336.4695.python-list@python.org>
Deutsch   English   Français   Italiano  
<mailman.33.1729781336.4695.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: MRAB <python@mrabarnett.plus.com>
Newsgroups: comp.lang.python
Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
Date: Thu, 24 Oct 2024 15:45:47 +0100
Lines: 93
Message-ID: <mailman.33.1729781336.4695.python-list@python.org>
References: <4a13731716200669342338ae409e73ca@posteo.de>
 <8d82b75d-a773-4854-bf44-cf480fdf3b84@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de QzdNSQOq7NUDDBNQgmd6CgXsUz2D11XqNRaxj4vrXLEw==
Cancel-Lock: sha1:PhW439fR43iRUxSyBRIRPFA80Po= sha256:fKR+gfvPmteDcu+fLVGPnuMFLwPfUfv06fqKVOzxXsw=
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=VrIp6xo9;
 dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04;
 'subject:when': 0.07; 'fails': 0.09; 'fedora': 0.09;
 'from:addr:python': 0.09; 'happens.': 0.09;
 'received:192.168.1.64': 0.09; 'skip:_ 20': 0.09; 'url-ip:140/8':
 0.14; '(especially': 0.16; 'assert': 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;
 '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; 'wrote:': 0.16; 'url-ip:140.82.121/24': 0.17; 'url-
 ip:140.82/16': 0.17; 'values': 0.17; 'code.': 0.19; 'solve': 0.19;
 'to:addr:python-list': 0.20; 'issue': 0.21; 'maybe': 0.22;
 'url:github': 0.23; 'idea': 0.24; 'seems': 0.26; 'do?': 0.26;
 'else': 0.27; 'output': 0.28; 'error': 0.29; 'header:User-
 Agent:1': 0.30; 'packages': 0.31; 'christian': 0.32; 'python-
 list': 0.32; 'received:192.168.1': 0.32; 'path': 0.33; 'header:In-
 Reply-To:1': 0.34; 'able': 0.34; "didn't": 0.34; 'item': 0.35;
 "we're": 0.35; 'those': 0.36; 'using': 0.37; 'directory': 0.37;
 'received:192.168': 0.37; 'file': 0.38; 'read': 0.38; 'thanks':
 0.39; 'use': 0.39; 'hello,': 0.39; 'break': 0.39; 'hand': 0.40;
 'should': 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; 'operate': 0.75; 'subsequent': 0.76; 'clue':
 0.84; 'behind': 0.88; 'replacing': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
 t=1729781148; bh=9j0uAbeWaCKxYRO7l6RYHwJnzllb9ep8cYeT4E7W9uE=;
 h=Date:Subject:To:References:From:In-Reply-To;
 b=VrIp6xo9ssdtSsgcfLOFs2wRfpm1aLNCfSvjTzx39psYb/1cTb7339ZGEyUYWUGfk
 yg+t3mxLstAbSizbbD9+pujBSLDQbb0dBxRxTInKXd4zjlyozyaXG0iGFa/pCl4ldB
 kAItmwi+jVXr2z2g0zCscOTKYB95Ps2zkbRJD+cNdFMTYrePgtK2Y3aFRdeklW0CPj
 XiUViYgd7iy69vZq2hdZvHNWaBh32oDXVAyvLDXePkyXnSU7rBc+aJVg6b5ypRevOP
 tgxYmI58Va+kTHnQVluVz3AmPkiWVjSRIM2g0gsq/796VpRqmcy7U+w+AIkt+R+k6g
 QnboAyrmaXl+A==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=XaAqz555 c=1 sm=1 tr=0 ts=671a5d9c
 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
 a=IkcTkHD0fZMA:10 a=NEAV23lmAAAA:8 a=edoF8RLc8VX77fFdq5UA:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <4a13731716200669342338ae409e73ca@posteo.de>
X-CMAE-Envelope: MS4xfDtHx69hEeP47b6GDNPaT7nk4vfI/TF7GhfBs/HljaD3h6H4KMETaewda5k1rFh4PlAqSstIk+RDUC0+fWGwExh3evBjALxYJLBl2CHJ1mhSWlDUoKOe
 gk5f1XZLBhPTbpcAIOezAFa+zFBM3LazbmS2Sp1xHVsQqbvCi7Z+n86jneqjYk3+3x4GGsVfJh3JQCkP4UarNyZzGeszBAdd9ZM=
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: <8d82b75d-a773-4854-bf44-cf480fdf3b84@mrabarnett.plus.com>
X-Mailman-Original-References: <4a13731716200669342338ae409e73ca@posteo.de>
Bytes: 8683

On 2024-10-24 08:33, Christian Buhtz via Python-list 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
> 
What does "mock" do?

func should be either os.close, os.rmdir or os.lstat.

If mock is somehow replacing one of those functions, then it might break 
the code.