From ea6fb2f54bbac0c2af71dcc8ad0a37a52d19ae86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= Date: Thu, 28 Apr 2022 13:47:44 +0200 Subject: [PATCH] Python 3.11: No longer use the undocumented sre_constants module --- ...se-undocumented-module-sre_constants.patch | 42 +++++++++++++++++++ pyparsing.spec | 8 +++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 0001-No-longer-use-undocumented-module-sre_constants.patch diff --git a/0001-No-longer-use-undocumented-module-sre_constants.patch b/0001-No-longer-use-undocumented-module-sre_constants.patch new file mode 100644 index 0000000..922bd75 --- /dev/null +++ b/0001-No-longer-use-undocumented-module-sre_constants.patch @@ -0,0 +1,42 @@ +From 9da4012a025294413fc1f956e081ee003df2411e Mon Sep 17 00:00:00 2001 +From: Serhiy Storchaka +Date: Thu, 28 Apr 2022 12:04:55 +0200 +Subject: [PATCH] No longer use undocumented module 'sre_constants' + +--- + pyparsing.py | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/pyparsing.py b/pyparsing.py +index 581d5bb..774222b 100644 +--- a/pyparsing.py ++++ b/pyparsing.py +@@ -105,7 +105,6 @@ import copy + import sys + import warnings + import re +-import sre_constants + import collections + import pprint + import traceback +@@ -3310,7 +3309,7 @@ class Regex(Token): + try: + self.re = re.compile(self.pattern, self.flags) + self.reString = self.pattern +- except sre_constants.error: ++ except re.error: + warnings.warn("invalid pattern (%s) passed to Regex" % pattern, + SyntaxWarning, stacklevel=2) + raise +@@ -3501,7 +3500,7 @@ class QuotedString(Token): + self.re = re.compile(self.pattern, self.flags) + self.reString = self.pattern + self.re_match = self.re.match +- except sre_constants.error: ++ except re.error: + warnings.warn("invalid pattern (%s) passed to Regex" % self.pattern, + SyntaxWarning, stacklevel=2) + raise +-- +2.33.1 + diff --git a/pyparsing.spec b/pyparsing.spec index 3568897..561e620 100644 --- a/pyparsing.spec +++ b/pyparsing.spec @@ -18,6 +18,11 @@ License: MIT URL: https://github.com/pyparsing/pyparsing Source0: https://github.com/%{name}/%{name}/archive/%{name}_%{version}/%{name}-%{version}.tar.gz +# sre_constants module is deprecated in Python 3.11, this patch replaces it with the re module +# Merged upstream in https://github.com/pyparsing/pyparsing/pull/379 +# Included in 3.0.8+ +Patch: 0001-No-longer-use-undocumented-module-sre_constants.patch + BuildArch: noarch BuildRequires: dos2unix BuildRequires: python%{python3_pkgversion}-devel @@ -72,7 +77,8 @@ This is the Python 3 version. %prep -%setup -q -n %{name}-%{name}_%{version} +%autosetup -p1 -n %{name}-%{name}_%{version} + dos2unix -k CHANGES LICENSE