From 71aef790d0370ea8be6b17bb4a623067746aa0f2 Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Wed, 26 Jul 2023 15:27:03 +0200 Subject: [PATCH] - Add preliminary support for Python 3.12b4 (fixes #149) --- .github/workflows/tests.yml | 2 ++ .meta.toml | 4 ++-- CHANGES.rst | 3 ++- src/zope/testrunner/tb_format.py | 17 ++++++++++++++++- tox.ini | 7 +++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1f774e6..928301b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,6 +27,7 @@ jobs: - ["3.9", "py39"] - ["3.10", "py310"] - ["3.11", "py311"] + - ["3.12.0-beta.4", "py312"] - ["pypy-3.9", "pypy3"] - ["3.9", "docs"] - ["3.9", "coverage"] @@ -39,6 +40,7 @@ jobs: exclude: - { os: ["windows", "windows-latest"], config: ["3.9", "lint"] } - { os: ["windows", "windows-latest"], config: ["3.9", "docs"] } + - { os: ["windows", "windows-latest"], config: ["3.9", "coverage"] } runs-on: ${{ matrix.os[1] }} if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name diff --git a/.meta.toml b/.meta.toml index 8343448..b1b5752 100644 --- a/.meta.toml +++ b/.meta.toml @@ -2,14 +2,14 @@ # https://github.com/zopefoundation/meta/tree/master/config/pure-python [meta] template = "pure-python" -commit-id = "66322213" +commit-id = "49beb029" [python] with-pypy = true with-docs = true with-sphinx-doctests = false with-windows = true -with-future-python = false +with-future-python = true with-macos = false [coverage] diff --git a/CHANGES.rst b/CHANGES.rst index 9fc4827..038b22c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,8 @@ 6.1 (unreleased) ================ -- Nothing changed yet. +- Add preliminary support for Python 3.12b4. + (`#149 `_) 6.0 (2023-03-28) diff --git a/src/zope/testrunner/tb_format.py b/src/zope/testrunner/tb_format.py index 0834ce3..97968bf 100644 --- a/src/zope/testrunner/tb_format.py +++ b/src/zope/testrunner/tb_format.py @@ -43,6 +43,20 @@ def _iter_chain(exc, custom_tb=None, seen=None): yield from it +def _parse_value_tb(exc, value, tb): + # Taken straight from the traceback module code on Python 3.10, which + # introduced the ability to call print_exception with an exception + # instance as first parameter + if (value is None) != (tb is None): + raise ValueError("Both or neither of value and tb must be given") + if value is tb is None: + if exc is not None: + return exc, exc.__traceback__ + else: + return None, None + return value, tb + + def format_exception(t, v, tb, limit=None, chain=None): if chain: values = _iter_chain(v, tb) @@ -56,7 +70,8 @@ def format_exception(t, v, tb, limit=None, chain=None): return fmt.formatException(t, v, tb) -def print_exception(t, v, tb, limit=None, file=None, chain=None): +def print_exception(t, v=None, tb=None, limit=None, file=None, chain=None): + v, tb = _parse_value_tb(t, v, tb) if chain: values = _iter_chain(v, tb) else: diff --git a/tox.ini b/tox.ini index b910f00..578021d 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ envlist = py39 py310 py311 + py312 pypy3 docs coverage @@ -16,7 +17,13 @@ envlist = [testenv] usedevelop = true +package = wheel +wheel_build_env = .pkg +pip_pre = py312: true deps = +setenv = + py312: VIRTUALENV_PIP=23.1.2 + py312: PIP_REQUIRE_VIRTUALENV=0 commands = zope-testrunner --test-path=src {posargs:-vc} extras =