From f179afce6580eeb9ac3581d4cc86f94e7a3a1bac Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Wed, 9 Feb 2022 15:32:46 +0100 Subject: [PATCH] Fix FutureWarning about nested sets in re Since Python 3.7 the re module warns for syntax which could, in the future, be misparsed as a nested set. Avoid this by escaping the literal `[` we search for in the regexp. Reported by Monte Davidoff @mndavidoff Closes #269. --- hg-fast-export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hg-fast-export.py b/hg-fast-export.py index 1658830..93f35bf 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -266,7 +266,7 @@ def sanitize_name(name,what="branch", mapping={}): if not auto_sanitize: return mapping.get(name,name) n=mapping.get(name,name) - p=re.compile(b'([[ ~^:?\\\\*]|\.\.)') + p=re.compile(b'([\\[ ~^:?\\\\*]|\.\.)') n=p.sub(b'_', n) if n[-1:] in (b'/', b'.'): n=n[:-1]+b'_' n=b'/'.join([dot(s) for s in n.split(b'/')])