From 67d3097f1f337b63d19f95470def367467af9fed 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
---
pipenv/vendor/attr/_compat.py | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/pipenv/vendor/attr/_compat.py b/pipenv/vendor/attr/_compat.py
index 6939f33..d385a7d 100644
--- a/pipenv/vendor/attr/_compat.py
+++ b/pipenv/vendor/attr/_compat.py
@@ -206,15 +206,22 @@ def make_set_closure_cell():
)
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():
--
2.37.3