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

regrtest: log unraisable exceptions and uncaught thread exceptions #81250

Closed
vstinner opened this issue May 27, 2019 · 6 comments
Closed

regrtest: log unraisable exceptions and uncaught thread exceptions #81250

vstinner opened this issue May 27, 2019 · 6 comments
Labels
3.8 only security fixes tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

BPO 37069
Nosy @vstinner
PRs
  • bpo-37069: regrtest: unraisable marks test as ENV_CHANGED #13759
  • bpo-37069: tests use catch_unraisable_exception() #13762
  • 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 2019-07-29.23:50:33.580>
    created_at = <Date 2019-05-27.22:51:24.824>
    labels = ['3.8', 'tests']
    title = 'regrtest: log unraisable exceptions and uncaught thread exceptions'
    updated_at = <Date 2019-07-29.23:50:33.579>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-07-29.23:50:33.579>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-07-29.23:50:33.580>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2019-05-27.22:51:24.824>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37069
    keywords = ['patch']
    message_count = 6.0
    messages = ['343693', '343696', '344341', '344365', '345425', '348705']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = ['13759', '13762']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37069'
    versions = ['Python 3.8']

    @vstinner
    Copy link
    Member Author

    Python 3.8 got 2 new hooks: sys.unraisablehook and threading.excepthook. It would be interesting to catch these exceptions and display them again in the test summary.

    I modified the io.IOBase destructor to log close() exception. There are still open issues: see bpo-18748. Once these issues will be fixed, maybe it would even be interesting to make a test fail if at least one uncaught thread exception is raised or an unraisable exception is logged?

    @vstinner vstinner added 3.8 only security fixes tests Tests in the Lib/test dir labels May 27, 2019
    @vstinner
    Copy link
    Member Author

    References:

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 3, 2019

    I wrote a minimum implementation: PR 13759 marks a test as "altered the execution environment" (ENV_CHANGED) if sys.unraisablehook() is called at least once. This this PR, 9 tests fail:

    • test_urllib: see bpo-36918

    • test_io: see bpo-18748

    • test_thread: test_save_exception_state_on_error()

    • test_yield_from: test_broken_getattr_handling()

    • test_coroutines: test_fatal_coro_warning()

    • test_cprofile: test_bad_counter_during_dealloc()

    • test_raise: test_3611()

    • test_ssl: test_sni_callback_raising() and test_sni_callback_wrong_return_type()

    • test_generators: I'm not sure, it's maybe caused by doctests? multiple tests?

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 3, 2019

    New changeset 0025350 by Victor Stinner in branch 'master':
    bpo-37069: tests use catch_unraisable_exception() (GH-13762)
    0025350

    @vstinner
    Copy link
    Member Author

    New changeset 95f61c8 by Victor Stinner in branch 'master':
    bpo-37069: regrtest uses sys.unraisablehook (GH-13759)
    95f61c8

    @vstinner
    Copy link
    Member Author

    regrtest now uses :func:`sys.unraisablehook` to mark a test as "environment altered" (ENV_CHANGED) if it emits an "unraisable exception".

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant