Skip to content

Backcompatibility broken for format_exception_only #98377

Closed as not planned
Closed as not planned
@zois-tasoulas

Description

@zois-tasoulas

Bug report

I think the change below breaks backwards compatibility,
91e9379#diff-96634ca56022c201d0ff677e922810a97e4ad8a55de53258cf0cbc22bd7c9be1R133

Specifically, usage of traceback.format_exception_only() that conforms to Python 3.10 signature, cannot be used on Python 3.8. Even if the argument value is provided.

A reproducible example would be:

import sys
import traceback

# Works on Python 3.8
try:
    raise Exception("test exception, pass")
except Exception as exc:
    exception_type, exception_value, _ = sys.exc_info()
    print(traceback.format_exception_only(exception_type, exception_value))

# Raises exception on Pyhton 3.8
try:
    raise Exception("test exception, fail")
except Exception as exc:
    _, exception_value, _ = sys.exc_info()
    print(traceback.format_exception_only(exc, exception_value))

Your environment

  • CPython versions tested on:
    Python 3.8.10

  • Operating system and architecture:
    Ubuntu 20.04.5 LTS, x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions