Skip to content

Windows ANSI initialization uses nonexistent subprocess.STD_OUTPUT_HANDLE #721

Open

Description

@MateehUllah

In fire/formatting_windows.py, initialize_or_disable() references a constant that does not exist in Python's subprocess module.

Problematic code

out_handle = kernel32.GetStdHandle(
    subprocess.STD_OUTPUT_HANDLE
)

Verification

import subprocess

print(hasattr(subprocess, 'STD_OUTPUT_HANDLE'))
# False

Expected behavior

The application should obtain the Windows standard output handle using a valid Win32 constant.

Actual behavior

When this code path executes, accessing the missing attribute would raise AttributeError.

Environment

This affects the Windows-specific code path when Colorama is installed, standard output is a terminal, and platform.release() returns '10'.

Testing

Verified that the attribute is absent. The complete Windows initialization path has not been tested on Windows.

Activity

  1. hugosmoreira commented on Oct 26, 2026

    @hugosmoreira

    I checked this on Windows 11 with CPython 3.13.15. hasattr(subprocess, 'STD_OUTPUT_HANDLE') returns True, and its value is 4294967285 (DWORD -11). On Windows, subprocess imports this constant from _winapi; my Linux control returns False.

    I also exercised the unchanged initializer with the Windows-10/TTY conditions forced and the native API calls mocked. It reached GetStdHandle and completed without the reported AttributeError. This was not a real Windows 10 console test.

    Could you share a failing Windows traceback and Python version?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy