New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-81927: Provide Windows predefined access type constants #20617
base: main
Are you sure you want to change the base?
Conversation
This draft PR adds an |
SET(ERROR_PIPE_BUSY); | ||
SET(ERROR_PIPE_CONNECTED); | ||
SET(ERROR_SEM_TIMEOUT); | ||
#undef SET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following error codes are listed twice: ERROR_MORE_DATA
, ERROR_NETNAME_DELETED
, and ERROR_NO_SYSTEM_RESOURCES
.
I'd also add the following common codes. Most of these have an explicit errno
mapping, but usually several codes map to the same errno
value.
SET(ERROR_GEN_FAILURE);
SET(ERROR_INVALID_FUNCTION);
SET(ERROR_NOT_SUPPORTED);
SET(ERROR_INVALID_PARAMETER);
SET(ERROR_INVALID_HANDLE);
SET(ERROR_INVALID_NAME);
SET(ERROR_BAD_NET_NAME);
SET(ERROR_BAD_PATHNAME);
SET(ERROR_FILENAME_EXCED_RANGE);
SET(ERROR_FILE_NOT_FOUND);
SET(ERROR_PATH_NOT_FOUND);
SET(ERROR_BAD_NETPATH);
SET(ERROR_NO_MORE_FILES);
SET(ERROR_FILE_EXISTS);
SET(ERROR_NOT_SAME_DEVICE);
SET(ERROR_DIRECTORY);
SET(ERROR_TOO_MANY_OPEN_FILES);
SET(ERROR_DISK_FULL);
SET(ERROR_DIR_NOT_EMPTY);
SET(ERROR_CANT_ACCESS_FILE);
SET(ERROR_CANT_RESOLVE_FILENAME);
SET(ERROR_NOT_A_REPARSE_POINT);
SET(ERROR_INVALID_REPARSE_DATA);
SET(ERROR_REPARSE_TAG_INVALID);
SET(ERROR_ACCESS_DENIED);
SET(ERROR_NETWORK_ACCESS_DENIED);
SET(ERROR_SHARING_VIOLATION);
SET(ERROR_LOCK_VIOLATION);
SET(ERROR_NOT_READY);
SET(ERROR_NOT_LOCKED);
SET(ERROR_LOCK_FAILED);
SET(ERROR_BAD_EXE_FORMAT);
SET(ERROR_NOT_ENOUGH_MEMORY);
SET(ERROR_NOT_ENOUGH_QUOTA);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are few more error codes to consider:
SET(ERROR_BAD_PIPE);
SET(ERROR_PIPE_NOT_CONNECTED);
SET(ERROR_PIPE_LISTENING);
SET(ERROR_ELEVATION_REQUIRED);
SET(ERROR_PRIVILEGE_NOT_HELD);
SET(ERROR_SYMLINK_CLASS_DISABLED);
ERROR_BAD_PIPE
is from NTSTATUS_INVALID_PIPE_STATE
orSTATUS_INVALID_READ_MODE
.ERROR_ELEVATION_REQUIRED
is returned byCreateProcessW
if an executable requires elevation (e.g. regedit.exe or osk.exe). It can be handled by callingShellExecute[Ex]W
with the "runas" verb.ERROR_PRIVILEGE_NOT_HELD
means the caller lacks a required privilege, or in some cases that the privilege isn't enabled.ERROR_SYMLINK_CLASS_DISABLED
means the system's L2L (local to local) symlink policy has disabled evaluation of local symlinks that target local paths. If the L2R (local to remote), R2L, or R2R policy is disabled,ERROR_NETWORK_ACCESS_DENIED
is set instead. The link can be resolved manually viaos.readlink
, but doing so violates system policy.
For checking exit status, here are some abnormal-termination status codes. This includes process initialization failures, unhandled exceptions, and unhandled console control events (Ctrl+C, Ctrl+Break, Ctrl+Close). Other than for testing purposes or providing a friendlier error message, usually there's nothing to handle in these cases.
SET(STATUS_ENTRYPOINT_NOT_FOUND);
SET(STATUS_DLL_NOT_FOUND);
SET(STATUS_ORDINAL_NOT_FOUND);
SET(STATUS_DLL_INIT_FAILED);
SET(STATUS_ACCESS_VIOLATION);
SET(STATUS_HEAP_CORRUPTION);
SET(STATUS_STACK_BUFFER_OVERRUN);
SET(STATUS_STACK_OVERFLOW);
SET(STATUS_ILLEGAL_INSTRUCTION);
SET(STATUS_PRIVILEGED_INSTRUCTION);
SET(STATUS_CONTROL_C_EXIT);
STATUS_STACK_BUFFER_OVERRUN
(0xC000_0409) is also used by the fastfail intrinsic, e.g. os.abort()
. The reason for the fastfail is included in the exception record and the corresponding Windows Error Reporting event in the application event log -- e.g. FAST_FAIL_FATAL_APP_EXIT
(7) for an abort.
If the process is still running, the status is STATUS_PENDING
. In the Windows API it's the same value aliased as STILL_ACTIVE
:
SET(STATUS_PENDING);
SET(STILL_ACTIVE);
SET(STANDARD_RIGHTS_EXECUTE); | ||
SET(STANDARD_RIGHTS_ALL); | ||
SET(SPECIFIC_RIGHTS_ALL); | ||
consts = _PyNamespace_New(d); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also include generic rights and the access-system right:
SET(GENERIC_READ);
SET(GENERIC_WRITE);
SET(GENERIC_EXECUTE);
SET(GENERIC_ALL);
SET(MAXIMUM_ALLOWED);
SET(ACCESS_SYSTEM_SECURITY);
The generic file mappings are also common for testing access:
SET(FILE_GENERIC_READ);
SET(FILE_GENERIC_WRITE);
SET(FILE_GENERIC_EXECUTE);
SET(FILE_ALL_ACCESS);
https://bugs.python.org/issue37746