Skip to content

Commit

Permalink
- Add preliminary support for Python 3.12b4 (fixes #149)
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Jul 26, 2023
1 parent 2c2c5ad commit 71aef79
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Expand Up @@ -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"]
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .meta.toml
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -5,7 +5,8 @@
6.1 (unreleased)
================

- Nothing changed yet.
- Add preliminary support for Python 3.12b4.
(`#149 <https://github.com/zopefoundation/zope.testrunner/issues/149>`_)


6.0 (2023-03-28)
Expand Down
17 changes: 16 additions & 1 deletion src/zope/testrunner/tb_format.py
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Expand Up @@ -9,14 +9,21 @@ envlist =
py39
py310
py311
py312
pypy3
docs
coverage
py{37,38,39,310,311,py3}-subunit

[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 =
Expand Down

0 comments on commit 71aef79

Please sign in to comment.