Skip to content

[Free Threading] test_importlib fails with "env changed": "Warning -- Unraisable exception" on some buildbots #162342

Closed

Description

@vstinner

test_importlib started to fails with "env changed" on:

Example on AMD64 CentOS9 NoGIL Refleaks 3.x: https://buildbot.python.org/#/builders/1610/builds/4375

test_lazy_self_referential_modules (test.test_importlib.test_lazy.LazyLoaderTests.test_lazy_self_referential_modules) ... ok
test_module_already_in_sys (test.test_importlib.test_lazy.LazyLoaderTests.test_module_already_in_sys) ... ok
test_module_load_race (test.test_importlib.test_lazy.LazyLoaderTests.test_module_load_race) ... ok
test_module_substitution_error (test.test_importlib.test_lazy.LazyLoaderTests.test_module_substitution_error) ... ok
test_mutated_attr (test.test_importlib.test_lazy.LazyLoaderTests.test_mutated_attr) ... ok
test_mutated_preexisting_attr (test.test_importlib.test_lazy.LazyLoaderTests.test_mutated_preexisting_attr) ... ok
test_new_attr (test.test_importlib.test_lazy.LazyLoaderTests.test_new_attr) ... ok
test_deadlock (test.test_importlib.test_locks.Frozen_DeadlockAvoidanceTests.test_deadlock) ... Warning -- Unraisable exception
Exception ignored while finalizing file <_io.FileIO name='/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/test_importlib/metadata/data/example-21.12-py3.6.egg' mode='rb' closefd=True>:
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/support/__init__.py", line 1004, in gc_collect
    gc.collect()
    ~~~~~~~~~~^^
ResourceWarning: unclosed file <_io.FileIO name='/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/test_importlib/metadata/data/example-21.12-py3.6.egg' mode='rb' closefd=True>
Warning -- Unraisable exception
Exception ignored while finalizing file <_io.FileIO name='/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/test_importlib/metadata/data/example-21.12-py3-none-any.whl' mode='rb' closefd=True>:
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/support/__init__.py", line 1004, in gc_collect
    gc.collect()
    ~~~~~~~~~~^^
ResourceWarning: unclosed file <_io.FileIO name='/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/test_importlib/metadata/data/example-21.12-py3-none-any.whl' mode='rb' closefd=True>
Warning -- Unraisable exception
Exception ignored while finalizing file <_io.FileIO name='/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/test_importlib/metadata/data/example2-1.0.0-py3-none-any.whl' mode='rb' closefd=True>:
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/support/__init__.py", line 1004, in gc_collect
    gc.collect()
    ~~~~~~~~~~^^
ResourceWarning: unclosed file <_io.FileIO name='/home/buildbot/buildarea/3.x.itamaro-centos-aws.refleak.nogil/build/Lib/test/test_importlib/metadata/data/example2-1.0.0-py3-none-any.whl' mode='rb' closefd=True>
ok

Linked PRs

Activity

  1. cmaloney commented on Nov 21, 2026

    @cmaloney
    Contributor

    Existing unclosed file was made visible by a finalization order change that gh-161184 caused. importlib.metadata.FastPath can contain a zipfile.Path which keeps alive a BufferedReader.

    Working on a PR.

  2. added a commit that references this issue on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions