From nobody Sat Feb 7 09:37:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570625955; cv=none; d=zoho.com; s=zohoarc; b=jqBIvJfUsO3oGghI7v7rlUbKH3zWJFNz6sm74xrlCSMKUgJSPMOgRJ1qSNgZnU3RKoA/VcgRpq1B02AWQXbgsPiDAM8EUPQculiOXOXh3LHqWF1t3U2/UE4jAFllyKZ4YfcPmKMUAXSqMJcA+iJNENfNcp4thKo0/C6+XaHR1ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570625955; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DANpLhNd1sOYlyszguoHiZqR+BhrcypLIQInm8Lcix0=; b=TbyDaeG7RP5WH2GcsHwzIu4XFy1/6wBhR4bDm+5IEEIJHexvvcqlKfMDUuwjSZRGx6wiR6SR5X0qAfwTVS5hKpcc3rNV9ZV3Rd2TWeH6Al/Aw1M7ldqcD1jDKQH144mjFZW0805Ckg3jWT5PYD1d04Y24Tp4YBkdXhQxqbpCIaE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570625955266814.4516221982037; Wed, 9 Oct 2019 05:59:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68F7510576D7; Wed, 9 Oct 2019 12:59:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4575A60BF4; Wed, 9 Oct 2019 12:59:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 05F064EE6D; Wed, 9 Oct 2019 12:59:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x99Cx2A6002952 for ; Wed, 9 Oct 2019 08:59:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F57C5D9D6; Wed, 9 Oct 2019 12:59:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AEF45D9CD; Wed, 9 Oct 2019 12:59:00 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 9 Oct 2019 13:58:38 +0100 Message-Id: <20191009125844.18202-5-berrange@redhat.com> In-Reply-To: <20191009125844.18202-1-berrange@redhat.com> References: <20191009125844.18202-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/10] python: mark regex strings with 'r' prefix X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Wed, 09 Oct 2019 12:59:13 +0000 (UTC) When writing regexes special regex matches like "\d" can get misinterpreted as normal string escape sequences: docs/apibuild.py:1359:51: W605 invalid escape sequence '\d' value =3D value + re.sub("^(\d+)U$", "\\1", token[1= ]) ^ docs/apibuild.py:2134:31: W605 invalid escape sequence '\(' m =3D re.match("\(?1<<(\d+)\)?", info[0]) ^ docs/apibuild.py:2134:38: W605 invalid escape sequence '\d' m =3D re.match("\(?1<<(\d+)\)?", info[0]) ^ docs/apibuild.py:2134:42: W605 invalid escape sequence '\)' m =3D re.match("\(?1<<(\d+)\)?", info[0]) ^ To avoid this probem all regexes should use the r"...." syntax for their strings, which disables normal string escape sequences. Signed-off-by: Daniel P. Berrang=C3=A9 --- build-aux/syntax-check.mk | 2 +- docs/apibuild.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 97255908b8..acd3f96c6d 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -884,7 +884,7 @@ FLAKE8_WHITESPACE =3D E211,E221,E222,E225,E226,E231,E261 FLAKE8_BLANK_LINES =3D E301,E302,E303,E305 FLAKE8_LINE_LENGTH =3D E501 FLAKE8_STATEMENTS =3D E722,E741 -FLAKE8_WARNINGS =3D W504,W605 +FLAKE8_WARNINGS =3D W504 =20 FLAKE8_IGNORE =3D $(FLAKE8_INDENTATION),$\ $(FLAKE8_WHITESPACE),$\ diff --git a/docs/apibuild.py b/docs/apibuild.py index dc52caf76d..18dc3604d0 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -665,7 +665,7 @@ class CParser: for line in lines: line =3D line.lstrip().lstrip('*').lstrip() =20 - m =3D re.match('([_.a-zA-Z0-9]+):(.*)', line) + m =3D re.match(r'([_.a-zA-Z0-9]+):(.*)', line) if m: item =3D m.group(1) line =3D m.group(2).lstrip() @@ -1333,7 +1333,7 @@ class CParser: while token[0] !=3D "sep" or (token[1] !=3D ',' and token[1] !=3D '}'): # We might be dealing with '1U << 12' here - value =3D value + re.sub("^(\d+)U$", "\\1", token[= 1]) + value =3D value + re.sub(r"^(\d+)U$", "\\1", token= [1]) token =3D self.token() else: try: @@ -2108,7 +2108,7 @@ class docBuilder: if valhex !=3D "": output.write(" value_hex=3D'%s'" % (valhex)) =20 - m =3D re.match("\(?1<<(\d+)\)?", info[0]) + m =3D re.match(r"\(?1<<(\d+)\)?", info[0]) if m: output.write(" value_bitshift=3D'%s'" % (m.group(1))) =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list