← 返回首页
asyncio unix events test doesn't restore mocked unix_events.can_use_pidfd · Issue #103780 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

asyncio unix events test doesn't restore mocked unix_events.can_use_pidfd #103780

New issue
New issue

Description

Bug report

in test_asyncio.test_unix_events.PolicyTest.test_get_default_child_watcher, unix_events.can_use_pidfd is mocked within the test body, but never restored to the original function.

this doesn't cause test failures during regular test runs, but during a refleak test run on MacOS it a AttributeError: module 'os' has no attribute 'pidfd_open' to be thrown (presumably due to another test using the non-mocked function in the second iteration).

repro:

./python.exe -m test test_asyncio -m '*.test_unix_events.*' -R 2:2 WARNING: Running tests with --huntrleaks/-R and less than 3 warmup repetitions can give false positives! 0:00:00 load avg: 3.79 Run tests sequentially 0:00:00 load avg: 3.79 [1/1] test_asyncio beginning 4 repetitions 1234 .Process ForkProcess-10: Traceback (most recent call last): ... ... AttributeError: module 'os' has no attribute 'pidfd_open' ... ...

this can be fixed by patching instead of mocking in the test_get_default_child_watcher test (PR coming up).

Your environment

  • CPython versions tested on: main
  • Operating system and architecture: MacOS x86-64

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.