This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author iritkatriel
Recipients iritkatriel
Date 2021-10-25.20:38:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635194281.32.0.0583100270803.issue45607@roundup.psfhosted.org>
In-reply-to
Content
The requirement comes from Hypothesis, see
https://github.com/python/cpython/pull/28569#discussion_r730338369

It is necessary there to add a note to an exception describing which test case it comes from. The note should be printed by __str__ of this exception. 


class Explanation(Exception):
    __module__ = "builtins"
    def __str__(self) -> str:
        return f"\n{self.args[0]}"

try:
    why = "Failed!"
    raise AssertionError(why)
except Exception as e:
    msg = "    You can reproduce this error by ...\n    ..."
    raise Explanation(msg) from e

    # Ideally something more like:
    e.__note__ = msg
    raise
History
Date User Action Args
2021-10-25 20:38:01iritkatrielsetrecipients: + iritkatriel
2021-10-25 20:38:01iritkatrielsetmessageid: <1635194281.32.0.0583100270803.issue45607@roundup.psfhosted.org>
2021-10-25 20:38:01iritkatriellinkissue45607 messages
2021-10-25 20:38:01iritkatrielcreate