Merge pull request #1427 from LeastAuthority/4158.invalid-escape-sequence
Some checks failed
CI / coverage (macos-14, 3.12) (push) Has been cancelled
CI / coverage (ubuntu-22.04, 3.12) (push) Has been cancelled
CI / coverage (ubuntu-22.04, pypy-3.9) (push) Has been cancelled
CI / coverage (windows-2022, 3.12) (push) Has been cancelled
CI / integration (false, macos-14, 3.11) (push) Has been cancelled
CI / integration (false, ubuntu-20.04, 3.11) (push) Has been cancelled
CI / integration (false, windows-2022, 3.11) (push) Has been cancelled
CI / integration (true, ubuntu-20.04, 3.12) (push) Has been cancelled
CI / packaging (macos-14, 3.9) (push) Has been cancelled
CI / packaging (ubuntu-22.04, 3.9) (push) Has been cancelled
CI / packaging (windows-2022, 3.9) (push) Has been cancelled
CI / finish-coverage-report (push) Has been cancelled

4158: Fix a bunch of "SyntaxWarning: invalid escape sequence"
This commit is contained in:
meejah 2025-01-15 13:05:09 -07:00 committed by GitHub
commit fc030da8df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 14 additions and 13 deletions

1
newsfragments/4158.minor Normal file
View File

@ -0,0 +1 @@
Fixed a couple of SyntaxWarnings from invalid escape sequences (shown under Python 3.12 and 3.13).

View File

@ -70,7 +70,7 @@ def roundup_pow2(x):
class CompleteBinaryTreeMixin: class CompleteBinaryTreeMixin:
""" r"""
Adds convenience methods to a complete binary tree. Adds convenience methods to a complete binary tree.
Assumes the total number of elements in the binary tree may be Assumes the total number of elements in the binary tree may be
@ -179,7 +179,7 @@ def pair_hash(a, b):
return tagged_pair_hash(b'Merkle tree internal node', a, b) return tagged_pair_hash(b'Merkle tree internal node', a, b)
class HashTree(CompleteBinaryTreeMixin, list): class HashTree(CompleteBinaryTreeMixin, list):
""" r"""
Compute Merkle hashes at any node in a complete binary tree. Compute Merkle hashes at any node in a complete binary tree.
Tree is indexed like so:: Tree is indexed like so::

View File

@ -406,7 +406,7 @@ class IStorageBucketWriter(Interface):
""" """
def put_uri_extension(data): def put_uri_extension(data):
"""This block of data contains integrity-checking information (hashes r"""This block of data contains integrity-checking information (hashes
of plaintext, crypttext, and shares), as well as encoding parameters of plaintext, crypttext, and shares), as well as encoding parameters
that are necessary to recover the data. This is a serialized dict that are necessary to recover the data. This is a serialized dict
mapping strings to other strings. The hash of this data is kept in mapping strings to other strings. The hash of this data is kept in

View File

@ -90,7 +90,7 @@ def _common_valid_config():
}) })
# group 1 will be addr (dotted quad string), group 3 if any will be portnum (string) # group 1 will be addr (dotted quad string), group 3 if any will be portnum (string)
ADDR_RE = re.compile("^([1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*)(:([1-9][0-9]*))?$") ADDR_RE = re.compile(r"^([1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*)(:([1-9][0-9]*))?$")
# this is put into README in new node-directories (for client and introducers) # this is put into README in new node-directories (for client and introducers)
PRIV_README = """ PRIV_README = """

View File

@ -36,9 +36,9 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
def count_output(self, out): def count_output(self, out):
mo = re.search(r"(\d)+ files uploaded \((\d+) reused\), " mo = re.search(r"(\d)+ files uploaded \((\d+) reused\), "
"(\d)+ files skipped, " r"(\d)+ files skipped, "
"(\d+) directories created \((\d+) reused\), " r"(\d+) directories created \((\d+) reused\), "
"(\d+) directories skipped", out) r"(\d+) directories skipped", out)
return [int(s) for s in mo.groups()] return [int(s) for s in mo.groups()]
def count_output2(self, out): def count_output2(self, out):

View File

@ -764,7 +764,7 @@ class Errors(GridTestMixin, CLITestMixin, unittest.TestCase):
# enough shares. The one remaining share might be in either the # enough shares. The one remaining share might be in either the
# COMPLETE or the PENDING state. # COMPLETE or the PENDING state.
in_complete_msg = "ran out of shares: complete=sh0 pending= overdue= unused= need 3" in_complete_msg = "ran out of shares: complete=sh0 pending= overdue= unused= need 3"
in_pending_msg_regex = "ran out of shares: complete= pending=Share\(.+\) overdue= unused= need 3" in_pending_msg_regex = r"ran out of shares: complete= pending=Share\(.+\) overdue= unused= need 3"
d.addCallback(lambda ign: self.do_cli("get", self.uri_1share)) d.addCallback(lambda ign: self.do_cli("get", self.uri_1share))
def _check1(args): def _check1(args):

View File

@ -254,7 +254,7 @@ class CreateNode(unittest.TestCase):
# Fail if there is a non-empty line that doesn't end with a # Fail if there is a non-empty line that doesn't end with a
# punctuation mark. # punctuation mark.
for line in err.splitlines(): for line in err.splitlines():
self.failIf(re.search("[\S][^\.!?]$", line), (line,)) self.failIf(re.search(r"[\S][^\.!?]$", line), (line,))
# test that the non --basedir form works too # test that the non --basedir form works too
n2 = os.path.join(basedir, command + "-n2") n2 = os.path.join(basedir, command + "-n2")

View File

@ -1968,7 +1968,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
def test_CSS_FILE(self): def test_CSS_FILE(self):
d = self.GET("/tahoe.css", followRedirect=True) d = self.GET("/tahoe.css", followRedirect=True)
def _check(res): def _check(res):
CSS_STYLE=re.compile(b'toolbar\s{.+text-align:\scenter.+toolbar-item.+display:\sinline',re.DOTALL) CSS_STYLE=re.compile(b'toolbar\\s{.+text-align:\\scenter.+toolbar-item.+display:\\sinline',re.DOTALL)
self.failUnless(CSS_STYLE.search(res), res) self.failUnless(CSS_STYLE.search(res), res)
d.addCallback(_check) d.addCallback(_check)
return d return d

View File

@ -189,7 +189,7 @@ class _Provider(service.MultiService):
privkeyfile = self._get_i2p_config("dest.private_key_file") privkeyfile = self._get_i2p_config("dest.private_key_file")
external_port = self._get_i2p_config("dest.port") external_port = self._get_i2p_config("dest.port")
sam_port = self._get_i2p_config("sam.port") sam_port = self._get_i2p_config("sam.port")
escaped_sam_port = sam_port.replace(':', '\:') escaped_sam_port = sam_port.replace(':', r'\:')
# for now, this returns a string, which then gets passed to # for now, this returns a string, which then gets passed to
# endpoints.serverFromString . But it can also return an Endpoint # endpoints.serverFromString . But it can also return an Endpoint
# directly, which means we don't need to encode all these options # directly, which means we don't need to encode all these options

View File

@ -1556,8 +1556,8 @@ class Statistics(MultiFormatResource):
def mangle_name(name): def mangle_name(name):
return re.sub( return re.sub(
u"_(\d\d)_(\d)_percentile", r"_(\d\d)_(\d)_percentile",
u'{quantile="0.\g<1>\g<2>"}', r'{quantile="0.\g<1>\g<2>"}',
name.replace(u".", u"_") name.replace(u".", u"_")
) )