GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — os.truncate() ignores _chsize_s() errors on Windows · Issue #159630 · python/cpython

os.truncate() ignores _chsize_s() errors on Windows #159630

New issue
Copy link
New issue
Copy link
Open
Open
os.truncate() ignores _chsize_s() errors on Windows#159630
Copy link
Labels
OS-windowsextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@aisk
aisk
opened on Oct 17, 2026
Issue body actions

Bug report

cpython/Modules/posixmodule.c

Lines 13651 to 13654 in a2c999b

result = _chsize_s(fd, length);
close(fd);
if (result < 0)
errno = result;

_chsize_s() returns 0 on success and a positive errno value on failure according to MS's document: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/chsize-s?view=msvc-170#return-value, but the code checks result < 0, so failures are silently ignored.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

  • gh-159630: Fix os.truncate() not raising OSError on Windows when truncation fails #159632

Activity

  1. aisk
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    OS-windows
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Oct 17, 2026
  2. kevinprimeraquecreo-stack
    added this to Project_VKand Project_VKon Oct 18, 2026
  3. github-project-automation
    moved this to Todo in Project_VKon Oct 18, 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

    OS-windowsextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.