Backport patch for Python 3.11 compatibility
This commit is contained in:
parent
ac0847eb2f
commit
93fc91df13
45
910.patch
Normal file
45
910.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From 87efa4fe80f8d4480d14de66c871bb9d6a4e1cb5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= <tinchester@gmail.com>
|
||||||
|
Date: Sun, 16 Jan 2022 02:37:19 +0100
|
||||||
|
Subject: [PATCH] Fix set_closure_cell on 3.11
|
||||||
|
|
||||||
|
---
|
||||||
|
src/attr/_compat.py | 25 ++++++++++++++++---------
|
||||||
|
1 file changed, 16 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/attr/_compat.py b/src/attr/_compat.py
|
||||||
|
index dc0cb02b..d1f30327 100644
|
||||||
|
--- a/src/attr/_compat.py
|
||||||
|
+++ b/src/attr/_compat.py
|
||||||
|
@@ -211,15 +211,22 @@ def force_x_to_be_a_cell(): # pragma: no cover
|
||||||
|
)
|
||||||
|
set_first_freevar_code = types.CodeType(*args)
|
||||||
|
|
||||||
|
- def set_closure_cell(cell, value):
|
||||||
|
- # Create a function using the set_first_freevar_code,
|
||||||
|
- # whose first closure cell is `cell`. Calling it will
|
||||||
|
- # change the value of that cell.
|
||||||
|
- setter = types.FunctionType(
|
||||||
|
- set_first_freevar_code, {}, "setter", (), (cell,)
|
||||||
|
- )
|
||||||
|
- # And call it to set the cell.
|
||||||
|
- setter(value)
|
||||||
|
+ if sys.version_info >= (3, 11):
|
||||||
|
+
|
||||||
|
+ def set_closure_cell(cell, value):
|
||||||
|
+ cell.cell_contents = value
|
||||||
|
+
|
||||||
|
+ else:
|
||||||
|
+
|
||||||
|
+ def set_closure_cell(cell, value):
|
||||||
|
+ # Create a function using the set_first_freevar_code,
|
||||||
|
+ # whose first closure cell is `cell`. Calling it will
|
||||||
|
+ # change the value of that cell.
|
||||||
|
+ setter = types.FunctionType(
|
||||||
|
+ set_first_freevar_code, {}, "setter", (), (cell,)
|
||||||
|
+ )
|
||||||
|
+ # And call it to set the cell.
|
||||||
|
+ setter(value)
|
||||||
|
|
||||||
|
# Make sure it works on this interpreter:
|
||||||
|
def make_func_with_cell():
|
||||||
@ -17,6 +17,8 @@ License: MIT
|
|||||||
URL: http://www.attrs.org/
|
URL: http://www.attrs.org/
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
Source0: https://github.com/hynek/%{modname}/archive/%{version}/%{modname}-%{version}.tar.gz
|
Source0: https://github.com/hynek/%{modname}/archive/%{version}/%{modname}-%{version}.tar.gz
|
||||||
|
# Python 3.11 compatibility
|
||||||
|
Patch910: https://github.com/python-attrs/attrs/pull/910.patch
|
||||||
|
|
||||||
BuildRequires: python%{python3_pkgversion}-devel
|
BuildRequires: python%{python3_pkgversion}-devel
|
||||||
BuildRequires: python%{python3_pkgversion}-setuptools
|
BuildRequires: python%{python3_pkgversion}-setuptools
|
||||||
@ -43,6 +45,7 @@ object protocols.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{modname}-%{version}
|
%setup -q -n %{modname}-%{version}
|
||||||
|
%patch910 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%py3_build
|
%py3_build
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user