Skip to content

Python may abort if unable to completely write a .pyc file in one go #141930

@stefanor

Description

@stefanor

Bug report

Bug description:

#126606 fixed a bug, in that writing incomplete .pyc files is not going to end well for the system.
But the solution was just to crash the file write, not attempt any retries.

It's not completely unexpected to receive a signal or some other interrupt that results in write() not writing all the provided data. This can be handled.

We've observed incomplete .pyc files in the past in Debian systems, and I just ran into this in a CI job:

https://people.debian.org/~stefanor/upstream/debusine-server_0.13.1.log

  Setting up python3-debusine-server (0.13.1) ...
  os.write() didn't write the full pyc filedpkg: error processing package python3-debusine-server (--configure):
   installed python3-debusine-server package post-installation script subprocess returned error exit status 1

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-IOtopic-importlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions