7
0
forked from pool/rpmdevtools
Files
rpmdevtools/limit_newversion_re.sub_to_a_single_replacement.patch
Martin Pluskal 237978c956 Accepting request 797224 from home:benoit_monin:branches:devel:tools
- Switch to python 3:
  * Require python3-rpm instead of python2-rpm
  * Add python3-shebang.patch to run python scripts with python3
  * Add rmdevelrpms_fix_filename_search.patch to add compatibility
    with both newer and older rpm binding
  * Backport upstream commits 2ddae80, 693c954 and ea772da

OBS-URL: https://build.opensuse.org/request/show/797224
OBS-URL: https://build.opensuse.org/package/show/devel:tools/rpmdevtools?expand=0&rev=26
2020-04-24 17:41:48 +00:00

36 lines
1.4 KiB
Diff

From ea772dae0d8bb266233c3fd9e2012281a821ef44 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Nov 02 2018 23:20:22 +0000
Subject: Limit newVersion's re.sub to a single replacement
Python 3.7 changed `re.sub` to replace empty matches next to a previous
non-empty match, which caused `SpecFile.newVersion` to double its
replacements. We can use `count=1` to limit this.
ref: https://bugs.python.org/issue32308
---
diff --git a/rpmdev-bumpspec b/rpmdev-bumpspec
index 35e6c9c..06737b5 100755
--- a/rpmdev-bumpspec
+++ b/rpmdev-bumpspec
@@ -134,13 +134,13 @@ class SpecFile(object):
original = self.lines[i]
if self.lines[i].lower().startswith('version:'):
self.lines[i] = re.sub(
- r'[^: \t]*$', v, self.lines[i].rstrip()) + '\n'
+ r'[^: \t]*$', v, self.lines[i].rstrip(), count=1) + '\n'
changed = changed or self.lines[i] != original
elif self.lines[i].lower().startswith('release:'):
# split and reconstruct to preserve whitespace
split = re.split(r':', self.lines[i].rstrip())
self.lines[i] = split[0] + ':' + \
- re.sub(r'[^ \t]*$', r, split[1]) + '\n'
+ re.sub(r'[^ \t]*$', r, split[1], count=1) + '\n'
changed = changed or self.lines[i] != original
return changed