Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency in C and python traceback printers #85203

Closed
msimacek mannequin opened this issue Jun 19, 2020 · 2 comments
Closed

Inconsistency in C and python traceback printers #85203

msimacek mannequin opened this issue Jun 19, 2020 · 2 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@msimacek
Copy link
Mannequin

msimacek mannequin commented Jun 19, 2020

BPO 41031
Nosy @serhiy-storchaka, @iritkatriel
PRs
  • bpo-41031: Match C and Python code formatting of unprintable exceptio… #28139
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-09-08.15:11:03.965>
    created_at = <Date 2020-06-19.08:54:18.929>
    labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
    title = 'Inconsistency in C and python traceback printers'
    updated_at = <Date 2021-09-08.15:11:03.964>
    user = 'https://bugs.python.org/msimacek'

    bugs.python.org fields:

    activity = <Date 2021-09-08.15:11:03.964>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-09-08.15:11:03.965>
    closer = 'iritkatriel'
    components = ['Library (Lib)']
    creation = <Date 2020-06-19.08:54:18.929>
    creator = 'msimacek'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41031
    keywords = ['patch']
    message_count = 2.0
    messages = ['371855', '401091']
    nosy_count = 3.0
    nosy_names = ['serhiy.storchaka', 'iritkatriel', 'msimacek']
    pr_nums = ['28139']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41031'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @msimacek
    Copy link
    Mannequin Author

    msimacek mannequin commented Jun 19, 2020

    I belive the python traceback module was designed to produce the same output as the internal exception printer (sys.__excepthook__), but this is not the case when the exception's __str__ raises an exception.

    Given an exception of the following class:
    class E(Exception):
    def __str__(self):
    raise RuntimeError

    Internal printer output:
    Traceback (most recent call last):
      File "inconsistent.py", line 6, in <module>
        raise E()
    __main__.E: <exception str() failed>
    
    traceback.print_exc output:
    Traceback (most recent call last):
      File "inconsistent.py", line 6, in <module>
        raise E()
    E: <unprintable E object>

    @msimacek msimacek mannequin added 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 19, 2020
    @iritkatriel iritkatriel added 3.9 only security fixes 3.11 only security fixes labels Sep 3, 2021
    @serhiy-storchaka
    Copy link
    Member

    New changeset 9e31b39 by Irit Katriel in branch 'main':
    bpo-41031: Match C and Python code formatting of unprintable exceptions and exceptions in the __main__ module. (GH-28139)
    9e31b39

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    JDevlieghere added a commit to llvm/llvm-project that referenced this issue Mar 15, 2023
    PythonDataObjectsTest.TestExceptions started failing because the output
    of the python traceback printers is now consistent between python and
    cpython [1]. Work around the issue by supporting both variants.
    
    Thanks to Ismail for identifying the root cause.
    
    [1] python/cpython#85203
    CarlosAlbertoEnciso pushed a commit to SNSystems/llvm-debuginfo-analyzer that referenced this issue Mar 17, 2023
    PythonDataObjectsTest.TestExceptions started failing because the output
    of the python traceback printers is now consistent between python and
    cpython [1]. Work around the issue by supporting both variants.
    
    Thanks to Ismail for identifying the root cause.
    
    [1] python/cpython#85203
    agozillon pushed a commit to ROCm-Developer-Tools/llvm-project that referenced this issue Mar 17, 2023
    PythonDataObjectsTest.TestExceptions started failing because the output
    of the python traceback printers is now consistent between python and
    cpython [1]. Work around the issue by supporting both variants.
    
    Thanks to Ismail for identifying the root cause.
    
    [1] python/cpython#85203
    JDevlieghere added a commit to apple/llvm-project that referenced this issue Apr 27, 2023
    PythonDataObjectsTest.TestExceptions started failing because the output
    of the python traceback printers is now consistent between python and
    cpython [1]. Work around the issue by supporting both variants.
    
    Thanks to Ismail for identifying the root cause.
    
    [1] python/cpython#85203
    
    (cherry picked from commit 9dbce77)
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants