1
0
python-pytest-benchmark/py311.patch

51 lines
1.6 KiB
Diff
Raw Normal View History

From b2f624afd68a3090f20187a46284904dd4baa4f6 Mon Sep 17 00:00:00 2001
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
Date: Tue, 17 Jan 2023 13:14:42 +0100
Subject: [PATCH] Python 3.11 compatibility
This patch adds the new arguments to the types.CodeType class
constructor in the clonefunc function.
See https://github.com/ionelmc/pytest-benchmark/issues/231
---
src/pytest_benchmark/compat.py | 1 +
src/pytest_benchmark/utils.py | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/pytest_benchmark/compat.py b/src/pytest_benchmark/compat.py
index 63d01bd..9afecf2 100644
--- a/src/pytest_benchmark/compat.py
+++ b/src/pytest_benchmark/compat.py
@@ -1,3 +1,4 @@
import sys
PY38 = sys.version_info[0] == 3 and sys.version_info[1] >= 8
+PY311 = sys.version_info[0] == 3 and sys.version_info[1] >= 11
diff --git a/src/pytest_benchmark/utils.py b/src/pytest_benchmark/utils.py
index c80352a..e28c04e 100644
--- a/src/pytest_benchmark/utils.py
+++ b/src/pytest_benchmark/utils.py
@@ -26,7 +26,7 @@ from urllib.parse import urlparse
import genericpath
-from .compat import PY38
+from .compat import PY38, PY311
# This is here (in the utils module) because it might be used by
# various other modules.
@@ -521,6 +521,10 @@ def clonefunc(f):
co.co_firstlineno, co.co_lnotab, co.co_freevars, co.co_cellvars]
if PY38:
args.insert(1, co.co_posonlyargcount)
+
+ if PY311:
+ args.insert(12, co.co_qualname)
+ args.insert(15, co.co_exceptiontable)
co2 = types.CodeType(*args)
#
# then, we clone the function itself, using the new co2
--
2.39.0