From patchwork Wed Oct 16 09:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1997879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IBO6Lr8r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XT4xc4gVnz1xvV for ; Wed, 16 Oct 2024 20:12:52 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D6FEF3857C58 for ; Wed, 16 Oct 2024 09:12:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id BE0BE3858C51 for ; Wed, 16 Oct 2024 09:12:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE0BE3858C51 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BE0BE3858C51 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729069941; cv=none; b=gvb8+J/iHPwdYbjVdo+TG9e5QuLgZQrCmm6nPlpFuXK/bAjrzJ0VtSG9CKrH8MScOW9/1tlVPjW/djDxqKh1w9rEEa2VPvjJ6ts+3xhjALVeYsm2O5I66VNv9zagmHvwqBmsCTAJ4H9aArH80pyEOPjjZvu8badH4ZDwajHm1Kw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729069941; c=relaxed/simple; bh=4DEQ9vT5hkfiaO8vDlea/FtVqWcmyAGx9suzJ+WtckQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=suGJy+tIrNXRNB9xgo44sFvncG01wEOcqWUtEl53sqOpuVbAPQSYe7W06KqIMr5FT5BJbKVuwVuFUxDo4Nz45a3PF5/oQB6P1t76GmC/ryXiZq9T9AvP/SwL3eDqGh7aeHX/knzvVwQO5y30+pg6A3gYst6U90bnTNdSGmQDZJI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729069938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fix+PVNldQmd4IAz6+KzeYHcuOErioQgQvjCBDrsbXg=; b=IBO6Lr8raYPkxtphIljfDNkE0oWgnf9MaDg25B5yLyE6Gmel1CaHZCr+dTtlEEn9f0UJ5F sdVXZBeNRNaupf55Cqtbc1yQORzpDEWA0/xyyP31n2K2mIveOK3H0I7YTboAHVf952NPA3 fLB0gVUbtm/Inrc3RF0qBFgXXoGfRjI= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-307-nWxfABhCPamv4tZxqw6dcQ-1; Wed, 16 Oct 2024 05:12:17 -0400 X-MC-Unique: nWxfABhCPamv4tZxqw6dcQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 04ECA1955F45; Wed, 16 Oct 2024 09:12:16 +0000 (UTC) Received: from localhost (unknown [10.42.28.16]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 57910195607C; Wed, 16 Oct 2024 09:12:13 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix Python deprecation warning in printers.py Date: Wed, 16 Oct 2024 10:11:42 +0100 Message-ID: <20241016091212.2263153-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-linux with gdb-15.1 and Python 3.12. Pushed to trunk, backports to follow. -- >8 -- python/libstdcxx/v6/printers.py:1355: DeprecationWarning: 'count' is passed as positional argument The Python docs say: Deprecated since version 3.13: Passing count and flags as positional arguments is deprecated. In future Python versions they will be keyword-only parameters. Using a keyword argument for count only became possible with Python 3.1 so introduce a new function to do the substitution. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (strip_fundts_namespace): New. (StdExpAnyPrinter, StdExpOptionalPrinter): Use it. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 92104937862..d05b79762fd 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -220,6 +220,16 @@ def strip_versioned_namespace(typename): return typename.replace(_versioned_namespace, '') +def strip_fundts_namespace(typ): + """Remove "fundamentals_vN" inline namespace from qualified type name.""" + pattern = r'^std::experimental::fundamentals_v\d::' + repl = 'std::experimental::' + if sys.version_info[0] == 2: + return re.sub(pattern, repl, typ, 1) + else: # Technically this needs Python 3.1 but nobody should be using 3.0 + return re.sub(pattern, repl, typ, count=1) + + def strip_inline_namespaces(type_str): """Remove known inline namespaces from the canonical name of a type.""" type_str = strip_versioned_namespace(type_str) @@ -1355,8 +1365,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) - self._typename = re.sub(r'^std::experimental::fundamentals_v\d::', - 'std::experimental::', self._typename, 1) + self._typename = strip_fundts_namespace(self._typename) self._val = val self._contained_type = None contained_value = None @@ -1449,10 +1458,8 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): """Print a std::optional or std::experimental::optional.""" def __init__(self, typename, val): - typename = strip_versioned_namespace(typename) - self._typename = re.sub( - r'^std::(experimental::|)(fundamentals_v\d::|)(.*)', - r'std::\1\3', typename, 1) + self._typename = strip_versioned_namespace(typename) + self._typename = strip_fundts_namespace(self._typename) payload = val['_M_payload'] if self._typename.startswith('std::experimental'): engaged = val['_M_engaged']