From 551ba911713c2859caabc91b664723dd6bc800c5 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Thu, 21 Dec 2023 12:39:35 +0200 Subject: [PATCH] Fix deprecation warnings in Python 3.12 (#22) * Fix deprecation warnings in Python 3.12 * remove -dev from 3.12 version --- .github/workflows/ci.yml | 2 +- pytest_examples/traceback.py | 21 ++++++++++++++++++++- requirements/testing.txt | 6 ++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffe2f34..72483f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] runs-on: ubuntu-latest steps: diff --git a/pytest_examples/traceback.py b/pytest_examples/traceback.py index 94ede45..41880fe 100644 --- a/pytest_examples/traceback.py +++ b/pytest_examples/traceback.py @@ -62,7 +62,26 @@ def create_custom_frame(frame: FrameType, example: CodeExample) -> FrameType: ctypes.pythonapi.PyThreadState_Get.restype = P_MEM_TYPE f_code = frame.f_code - if sys.version_info >= (3, 11): + if sys.version_info >= (3, 12): + code = CodeType( + f_code.co_argcount, + f_code.co_posonlyargcount, + f_code.co_kwonlyargcount, + f_code.co_nlocals, + f_code.co_stacksize, + f_code.co_flags, + f_code.co_code, + f_code.co_consts, + f_code.co_names, + f_code.co_varnames, + str(example.path), + f_code.co_name, + f_code.co_qualname, + f_code.co_firstlineno + example.start_line, + f_code.co_linetable, + f_code.co_exceptiontable, + ) + elif sys.version_info >= (3, 11): code = CodeType( f_code.co_argcount, f_code.co_posonlyargcount, diff --git a/requirements/testing.txt b/requirements/testing.txt index 805175d..4b42722 100644 --- a/requirements/testing.txt +++ b/requirements/testing.txt @@ -2,10 +2,8 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --output-file=requirements/testing.txt --resolver=backtracking requirements/testing.in +# pip-compile --output-file=requirements/testing.txt requirements/testing.in # -attrs==22.2.0 - # via pytest coverage==7.2.2 # via -r requirements/testing.in exceptiongroup==1.1.1 @@ -22,7 +20,7 @@ pluggy==1.0.0 # via pytest pygments==2.14.0 # via rich -pytest==7.2.2 +pytest==7.4.2 # via pytest-pretty pytest-pretty==1.1.1 # via -r requirements/testing.in