New submission from Florian Bruhin <python....@the-compiler.org>:

After upgrading to 3.10a5, calling logging.exception("test") results in:

    --- Logging error ---
    Traceback (most recent call last):
      File "/usr/lib/python3.10/logging/__init__.py", line 1094, in emit
        msg = self.format(record)
      File "/usr/lib/python3.10/logging/__init__.py", line 938, in format
        return fmt.format(record)
      File "/usr/lib/python3.10/logging/__init__.py", line 682, in format
        record.exc_text = self.formatException(record.exc_info)
      File "/usr/lib/python3.10/logging/__init__.py", line 632, in 
formatException
        traceback.print_exception(ei[0], ei[1], tb, None, sio)
      File "/usr/lib/python3.10/traceback.py", line 113, in print_exception
        te = TracebackException(type(value), value, tb, limit=limit, 
compact=True)
      File "/usr/lib/python3.10/traceback.py", line 531, in __init__
        need_context = cause is None and not e.__suppress_context__
    AttributeError: 'NoneType' object has no attribute '__suppress_context__'

That method is documented as "This function should only be called from an 
exception handler.", but the same also happens when e.g. calling 
traceback.print_exc() (without a current exception) or 
traceback.print_exception(None, None, None). Both worked fine before 3.10 Alpha 
5, the code seems to do None-checks in other places, and typeshed also marks 
those arguments as Optional.

This seems to have been introduced in 
https://github.com/python/cpython/pull/24179 for bpo-42877.

----------
components: Library (Lib)
messages: 386562
nosy: The Compiler, iritkatriel, vinay.sajip
priority: normal
severity: normal
status: open
title: 3.10a5 regression: AttributeError: 'NoneType' object has no attribute 
'__suppress_context__' in traceback.py
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43146>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to