Content-Length: 308856 | pFad | https://github.com/python/cpython/issues/113358

CA Exception with broken __getattr__ causes error rendering tracebacks · Issue #113358 · python/cpython · GitHub
Skip to content

Exception with broken __getattr__ causes error rendering tracebacks #113358

@perrinjerome

Description

@perrinjerome

Bug report

Bug description:

Running this code:

import logging

class X(Exception):
    def __getattr__(self, a):
        raise KeyError(a)  # !!!

try:
    raise X()
except X:
    logging.getLogger().exception('')

print('ok')

does not print "ok" but instead:

# python3.11 repro.py 
--- Logging error ---
Traceback (most recent call last):
  File "/workspaces/cpython/repro.py", line 8, in <module>
    raise X()
object address  : 0x7f3007c67e80
object refcount : 2
object type     : 0x7f3015bf0b20
object type name: KeyError
object repr     : KeyError('__notes__')
lost sys.stderr

CPython versions tested on:

3.11, CPython main branch

Operating systems tested on:

Linux

Linked PRs

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









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/113358

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy