summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2018-12-29 18:07:00 +0100
committerGuido Günther <agx@sigxcpu.org>2018-12-29 18:31:54 +0100
commit81bfe17332794a61d3cf9c741931b05c278efcd1 (patch)
tree83723a10a06baf20330b263c8b601d1fe3a1c306
parentcd4c4d29474b1a22d16bf218be799f6698183d21 (diff)
rpm_ch: Escape \S in regex replacement
Replace the \S in the substitution. Otherwise we fail on Python3.7 like ====================================================================== ERROR: Test determining the author name/email ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/python3.7/sre_parse.py", line 1021, in parse_template this = chr(ESCAPES[this][1]) KeyError: '\\S' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/var/scratch/src/git-buildpackage/git-buildpackage/tests/component/rpm/test_rpm_ch.py", line 182, in test_author eq_(mock_ch([]), 0) File "/var/scratch/src/git-buildpackage/git-buildpackage/tests/component/rpm/test_rpm_ch.py", line 37, in mock_ch '--spawn-editor=never'] + args) File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/rpm_ch.py", line 422, in main since = get_start_commit(ch_file.changelog, repo, options) File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/rpm_ch.py", line 230, in get_start_commit since = guess_commit(changelog.sections[0], repo, options) File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/scripts/rpm_ch.py", line 180, in guess_commit options.changelog_revision) File "/usr/lib/python3.7/re.py", line 192, in sub return _compile(pattern, flags).sub(repl, string, count) File "/usr/lib/python3.7/re.py", line 309, in _subx template = _compile_repl(template, pattern) File "/usr/lib/python3.7/re.py", line 300, in _compile_repl return sre_parse.parse_template(repl, pattern) File "/usr/lib/python3.7/sre_parse.py", line 1024, in parse_template raise s.error('bad escape %s' % this, len(this)) re.error: bad escape \S at position 7
-rw-r--r--gbp/scripts/rpm_ch.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/gbp/scripts/rpm_ch.py b/gbp/scripts/rpm_ch.py
index 9212f717..9cb99a25 100644
--- a/gbp/scripts/rpm_ch.py
+++ b/gbp/scripts/rpm_ch.py
@@ -176,7 +176,7 @@ def guess_commit(section, repo, options):
header = section.header
# Try to parse the fields from the header revision
- rev_re = '^%s$' % re.sub(r'%\((\S+?)\)s', r'(?P<\1>\S+)',
+ rev_re = '^%s$' % re.sub(r'%\((\S+?)\)s', r'(?P<\1>\\S+)',
options.changelog_revision)
match = re.match(rev_re, header['revision'], re.I)
fields = match.groupdict() if match else {}