From 4f4b32b780ff32434b0bf55b837fe72bf61f1989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 7 Jul 2022 10:48:18 +0200 Subject: [PATCH] Don't import deprecated sre_parse and sre_constants modules Related to https://bugzilla.redhat.com/show_bug.cgi?id=2098971#c6 --- python-lark-parser.spec | 12 ++++++++++-- python3.11.patch | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 python3.11.patch diff --git a/python-lark-parser.spec b/python-lark-parser.spec index 0a66e3f..3c52353 100644 --- a/python-lark-parser.spec +++ b/python-lark-parser.spec @@ -2,11 +2,16 @@ Name: python-%{pypi_name} Version: 0.9.0 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Lark is a modern general-purpose parsing library for Python License: MIT Url: https://github.com/lark-parser/lark Source: https://files.pythonhosted.org/packages/source/l/%{pypi_name}/%{pypi_name}-%{version}.tar.gz + +# Adjust imports for Python 3.11, merged upstream +# https://github.com/lark-parser/lark/pull/1140 +Patch: python3.11.patch + BuildArch: noarch %description @@ -74,7 +79,7 @@ Features: - Unicode fully supported %prep -%autosetup -n %{pypi_name}-%{version} +%autosetup -p1 -n %{pypi_name}-%{version} %build %py3_build @@ -93,6 +98,9 @@ rm -rfv %{buildroot}/%{python3_sitelib}/lark-stubs/ %{python3_sitelib}/lark/ %changelog +* Thu Jul 07 2022 Miro HronĨok - 0.9.0-7 +- Don't import deprecated sre_parse and sre_constants modules + * Mon Jun 13 2022 Python Maint - 0.9.0-6 - Rebuilt for Python 3.11 diff --git a/python3.11.patch b/python3.11.patch new file mode 100644 index 0000000..59a9aed --- /dev/null +++ b/python3.11.patch @@ -0,0 +1,33 @@ +From 7bbb353dd258905510289bda3de87a8354daca3c Mon Sep 17 00:00:00 2001 +From: Florian Bruhin +Date: Tue, 26 Apr 2022 13:37:12 +0200 +Subject: [PATCH] Adjust imports for Python 3.11 + +sre_parse and sre_constants are deprecated in 3.11, see https://github.com/python/cpython/issues/91308 +--- + lark/utils.py | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/lark/utils.py b/lark/utils.py +index 36f50d1..29d998b 100644 +--- a/lark/utils.py ++++ b/lark/utils.py +@@ -173,8 +173,13 @@ except ImportError: + import sys, re + Py36 = (sys.version_info[:2] >= (3, 6)) + +-import sre_parse +-import sre_constants ++if sys.version_info >= (3, 11): ++ import re._parser as sre_parse ++ import re._constants as sre_constants ++else: ++ import sre_parse ++ import sre_constants ++ + categ_pattern = re.compile(r'\\p{[A-Za-z_]+}') + def get_regexp_width(expr): + if regex: +-- +2.35.3 +