Fix regex substitution issues with Python 3.7 (rhbz#1651954)

This commit is contained in:
Neal Gompa 2018-11-28 23:10:30 -05:00
parent e47f8797e3
commit a488e997ab
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,37 @@
From ea772dae0d8bb266233c3fd9e2012281a821ef44 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 2 Nov 2018 16:20:22 -0700
Subject: [PATCH] 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
---
rpmdev-bumpspec | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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
--
2.17.2

View File

@ -8,7 +8,7 @@
Name: rpmdevtools Name: rpmdevtools
Version: 8.10 Version: 8.10
Release: 6%{?dist} Release: 7%{?dist}
Summary: RPM Development Tools Summary: RPM Development Tools
# rpmdev-setuptree is GPLv2, everything else GPLv2+ # rpmdev-setuptree is GPLv2, everything else GPLv2+
@ -18,6 +18,7 @@ Source0: https://releases.pagure.org/rpmdevtools/%{name}-%{version}.tar.x
# Backports from upstream # Backports from upstream
Patch0001: 0001-bumpspec-checksig-Avoid-python-3.6-regex-related-dep.patch Patch0001: 0001-bumpspec-checksig-Avoid-python-3.6-regex-related-dep.patch
Patch0002: 0001-Limit-newVersion-s-re.sub-to-a-single-replacement.patch
BuildArch: noarch BuildArch: noarch
# help2man, pod2man, *python for creating man pages # help2man, pod2man, *python for creating man pages
@ -126,6 +127,9 @@ done
%changelog %changelog
* Wed Nov 28 2018 Neal Gompa <ngompa13@gmail.com> - 8.10-7
- Fix regex substitution issues with Python 3.7 (rhbz#1651954)
* Sun Sep 16 2018 Neal Gompa <ngompa13@gmail.com> - 8.10-6 * Sun Sep 16 2018 Neal Gompa <ngompa13@gmail.com> - 8.10-6
- Fix regex related deprecation warnings (rhbz#1598089) - Fix regex related deprecation warnings (rhbz#1598089)