Registry / devops / ntstatus

ntstatus

JSON →
library2.0pypypi✓ verified 79d ago

Python enum for NTSTATUS codes from the Windows API (ntstatus.h). Allows comparison to both signed and unsigned integers. Version 2.0 dropped Python 3.9 support. Maintained on GitHub.

pip install ntstatus
INSTALL
IMPORT
SIG · NTSTATUS
N
ntstatus
devopspythonv2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NtStatus
from ntstatus import NtStatus
from ntstatus import NTSTATUS
HResult
from ntstatus import HResult
Win32Error
from ntstatus import Win32Error

Basic usage of NTSTATUS enum: instantiation, comparison, and name lookup.

from ntstatus import NTSTATUS # Convert a hex value to enum constant status = NTSTATUS(0xC0000022) # STATUS_ACCESS_DENIED print(status) # NTSTATUS.STATUS_ACCESS_DENIED # Comparison with int (both signed and unsigned) if status == 0xC0000022: print('Access denied') # Get constant from name from ntstatus.status import STATUS_ACCESS_DENIED print(STATUS_ACCESS_DENIED.value) # -1073741790 (signed)
Debug
Known issues
breakingVersion 2.0 dropped support for Python 3.9 and removed legacy enum import patterns. Python >=3.10 required.
fix
Upgrade Python to 3.10+ or pin ntstatus==1.0 for Python 3.9.
affects: 2.0
deprecatedDirect import from `ntstatus.constants` is deprecated; use `ntstatus.status` instead.
fix
Replace `from ntstatus.constants import ...` with `from ntstatus.status import ...`.
affects: >=2.0
gotchaComparing NTSTATUS enum directly with negative ints (signed) works, but unsigned (hex) comparisons may raise TypeError if not using the enum's custom __eq__.
fix
Always use NTSTATUS(value) or compare against NTSTATUS constants; avoid raw int comparisons unless you understand the sign handling.
affects: all
Upgrade
Version history
2.0latest on PyPI · released Jun 11, 2025
Audit
Dependencies
typing_extensionsoptionalUsed for enum decorators only in Python <3.11
Agent activity
9 hits · last 30 days
node
8
Resources
ntstatus — pip install ntstatus · libregistry