diff --git a/0001-Use-CodeType.replace-in-copycode-for-Python-3.8.patch b/0001-Use-CodeType.replace-in-copycode-for-Python-3.8.patch new file mode 100644 index 0000000..518a8e3 --- /dev/null +++ b/0001-Use-CodeType.replace-in-copycode-for-Python-3.8.patch @@ -0,0 +1,58 @@ +From 8462d7cc42f64c4584661188966b14f905aa3da1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= +Date: Mon, 14 Feb 2022 00:40:44 +0100 +Subject: [PATCH] Use CodeType.replace() in copycode for Python > 3.8 + +Fix #135 +--- + automat/_introspection.py | 34 ++++++++++++++++++---------------- + 1 file changed, 18 insertions(+), 16 deletions(-) + +diff --git a/automat/_introspection.py b/automat/_introspection.py +index 3f7307d..0ce9037 100644 +--- a/automat/_introspection.py ++++ b/automat/_introspection.py +@@ -6,22 +6,24 @@ from types import CodeType as code, FunctionType as function + + + def copycode(template, changes): +- names = [ +- "argcount", "nlocals", "stacksize", "flags", "code", "consts", +- "names", "varnames", "filename", "name", "firstlineno", "lnotab", +- "freevars", "cellvars" +- ] +- if hasattr(code, "co_kwonlyargcount"): +- names.insert(1, "kwonlyargcount") +- if hasattr(code, "co_posonlyargcount"): +- # PEP 570 added "positional only arguments" +- names.insert(1, "posonlyargcount") +- values = [ +- changes.get(name, getattr(template, "co_" + name)) +- for name in names +- ] +- return code(*values) +- ++ if hasattr(code, "replace"): ++ return template.replace(**{"co_" + k : v for k, v in changes.items()}) ++ else: ++ names = [ ++ "argcount", "nlocals", "stacksize", "flags", "code", "consts", ++ "names", "varnames", "filename", "name", "firstlineno", "lnotab", ++ "freevars", "cellvars" ++ ] ++ if hasattr(code, "co_kwonlyargcount"): ++ names.insert(1, "kwonlyargcount") ++ if hasattr(code, "co_posonlyargcount"): ++ # PEP 570 added "positional only arguments" ++ names.insert(1, "posonlyargcount") ++ values = [ ++ changes.get(name, getattr(template, "co_" + name)) ++ for name in names ++ ] ++ return code(*values) + + + def copyfunction(template, funcchanges, codechanges): +-- +2.34.1 + diff --git a/python-Automat.spec b/python-Automat.spec index da9a425..f8bc9cf 100644 --- a/python-Automat.spec +++ b/python-Automat.spec @@ -21,6 +21,8 @@ Summary: Self-service finite-state machines for the programmer on the go License: MIT URL: https://github.com/glyph/automat Source0: %pypi_source +# https://github.com/glyph/automat/issues/135 +Patch0: 0001-Use-CodeType.replace-in-copycode-for-Python-3.8.patch BuildArch: noarch @@ -29,7 +31,6 @@ BuildArch: noarch %package -n python3-%{pkgname} Summary: %{summary} Provides: python3-%{libname} -%{?python_provide:%python_provide python3-%{pkgname}} BuildRequires: python3-devel BuildRequires: python3dist(m2r)