Skip to content

Commit

Permalink
Merge pull request tahoe-lafs#1427 from LeastAuthority/4158.invalid-e…
Browse files Browse the repository at this point in the history
…scape-sequence

4158: Fix a bunch of "SyntaxWarning: invalid escape sequence"
  • Loading branch information
meejah authored Jan 15, 2025
2 parents a1efd53 + dc65ecf commit fc030da
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions newsfragments/4158.minor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a couple of SyntaxWarnings from invalid escape sequences (shown under Python 3.12 and 3.13).
4 changes: 2 additions & 2 deletions src/allmydata/hashtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def roundup_pow2(x):


class CompleteBinaryTreeMixin:
"""
r"""
Adds convenience methods to a complete binary tree.
Assumes the total number of elements in the binary tree may be
Expand Down Expand Up @@ -179,7 +179,7 @@ def pair_hash(a, b):
return tagged_pair_hash(b'Merkle tree internal node', a, b)

class HashTree(CompleteBinaryTreeMixin, list):
"""
r"""
Compute Merkle hashes at any node in a complete binary tree.
Tree is indexed like so::
Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def put_share_hashes(sharehashes):
"""

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
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
Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _common_valid_config():
})

# 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)
PRIV_README = """
Expand Down
6 changes: 3 additions & 3 deletions src/allmydata/test/cli/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def writeto(self, path, data):

def count_output(self, out):
mo = re.search(r"(\d)+ files uploaded \((\d+) reused\), "
"(\d)+ files skipped, "
"(\d+) directories created \((\d+) reused\), "
"(\d+) directories skipped", out)
r"(\d)+ files skipped, "
r"(\d+) directories created \((\d+) reused\), "
r"(\d+) directories skipped", out)
return [int(s) for s in mo.groups()]

def count_output2(self, out):
Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/test/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def _stash_bad(ur):
# enough shares. The one remaining share might be in either the
# COMPLETE or the PENDING state.
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))
def _check1(args):
Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/test/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def do_create(self, kind, *args):
# Fail if there is a non-empty line that doesn't end with a
# punctuation mark.
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
n2 = os.path.join(basedir, command + "-n2")
Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/test/web/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ def test_GET_FILEURL_badtype(self):
def test_CSS_FILE(self):
d = self.GET("/tahoe.css", followRedirect=True)
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)
d.addCallback(_check)
return d
Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/util/i2p_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def get_listener(self):
privkeyfile = self._get_i2p_config("dest.private_key_file")
external_port = self._get_i2p_config("dest.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
# endpoints.serverFromString . But it can also return an Endpoint
# directly, which means we don't need to encode all these options
Expand Down
4 changes: 2 additions & 2 deletions src/allmydata/web/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,8 +1556,8 @@ def render_OPENMETRICS(self, req):

def mangle_name(name):
return re.sub(
u"_(\d\d)_(\d)_percentile",
u'{quantile="0.\g<1>\g<2>"}',
r"_(\d\d)_(\d)_percentile",
r'{quantile="0.\g<1>\g<2>"}',
name.replace(u".", u"_")
)

Expand Down

0 comments on commit fc030da

Please sign in to comment.