From aec511d1a62c6e3e6be4b4d2b6371b11bdb992e4 Mon Sep 17 00:00:00 2001 From: Gordon Ball <gordon@chronitis.net> Date: Mon, 10 Oct 2022 07:41:51 +0000 Subject: [PATCH] New upstream version 0.5.1 --- .github/workflows/pytest.yml | 2 +- setup.cfg | 1 + stack_data/core.py | 2 +- stack_data/serializing.py | 3 ++- stack_data/utils.py | 8 ++++++++ tests/test_core.py | 2 +- tox.ini | 2 +- 7 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b3491e4..681508e 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev] + python-version: [3.6, 3.7, 3.8, 3.9, '3.10', 3.11-dev] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/setup.cfg b/setup.cfg index 535dfd5..dc8b29b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,6 +15,7 @@ classifiers = Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 License :: OSI Approved :: MIT License Operating System :: OS Independent Topic :: Software Development :: Debuggers diff --git a/stack_data/core.py b/stack_data/core.py index 813719c..e2ca2d5 100644 --- a/stack_data/core.py +++ b/stack_data/core.py @@ -154,7 +154,7 @@ class Source(executing.Source): for name, body in ast.iter_fields(stmt): if ( isinstance(body, list) and body and - isinstance(body[0], (ast.stmt, ast.ExceptHandler)) + isinstance(body[0], (ast.stmt, ast.ExceptHandler, getattr(ast, 'match_case', ()))) ): for rang, group in sorted(group_by_key_func(body, line_range).items()): sub_stmt = group[0] diff --git a/stack_data/serializing.py b/stack_data/serializing.py index fb67d29..0d813f6 100644 --- a/stack_data/serializing.py +++ b/stack_data/serializing.py @@ -15,6 +15,7 @@ from stack_data import ( Variable, RepeatedFrames, ) +from stack_data.utils import some_str log = logging.getLogger(__name__) @@ -92,7 +93,7 @@ class Serializer: frames=self.format_stack(e.__traceback__ or sys.exc_info()[2]), exception=dict( type=type(e).__name__, - message=traceback._some_str(e), + message=some_str(e), ), tail="", ) diff --git a/stack_data/utils.py b/stack_data/utils.py index 71d55ea..9cd0633 100644 --- a/stack_data/utils.py +++ b/stack_data/utils.py @@ -170,3 +170,11 @@ def assert_(condition, error=""): if isinstance(error, str): error = AssertionError(error) raise error + + +# Copied from the standard traceback module pre-3.11 +def some_str(value): + try: + return str(value) + except: + return '<unprintable %s object>' % type(value).__name__ diff --git a/tests/test_core.py b/tests/test_core.py index 0bcbe04..870497d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -467,7 +467,7 @@ def test_skipping_frames(): def sys_modules_sources(): - for module in sys.modules.values(): + for module in list(sys.modules.values()): try: filename = inspect.getsourcefile(module) except TypeError: diff --git a/tox.ini b/tox.ini index bebb6eb..b613d58 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{36,37,38,39,310} +envlist = py{36,37,38,39,310,311} [testenv] commands = pytest {posargs} -- GitLab