Skip to content

Pickle closed-file loading test exercises dumping instead of loading #159361

Description

@esadomer

In Lib/test/pickletester.py, test_load_closed_file calls self.dump, duplicating test_dump_closed_file instead of exercising self.load on a closed file.

The existing assertion is:

self.assertRaises(ValueError, self.dump, 123, f)

The loading test should open a readable binary file, close it, and assert that self.load(f) raises ValueError. This restores coverage of the intended failure path for both Python and C pickle implementations.

Verified on CPython main at 9ed41860b411144dbb6d2e4f53489d432364fd19: the corrected cases pass with the real loaders and fail when the loaders are replaced with no-ops. The complete test_pickle module passed on a Windows debug build.

Linked PRs

Activity

  1. added 2 commits that reference this issue on Oct 13, 2026
  2. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    on Oct 14, 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

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions