@@ -175,7 +175,9 @@ if sys.platform == "win32":
175175 if sys .version_info >= (3 , 14 ):
176176 COPY_FILE_DIRECTORY : Final = 0x00000080
177177
178- def CloseHandle (handle : int , / ) -> None : ...
178+ def CloseHandle (handle : int , / ) -> None :
179+ """Close handle.
180+ """
179181 @overload
180182 def ConnectNamedPipe (handle : int , overlapped : Literal [True ]) -> Overlapped : ...
181183 @overload
@@ -204,7 +206,14 @@ if sys.platform == "win32":
204206 security_attributes : int ,
205207 / ,
206208 ) -> int : ...
207- def CreatePipe (pipe_attrs : Any , size : int , / ) -> tuple [int , int ]: ...
209+ def CreatePipe (pipe_attrs : Any , size : int , / ) -> tuple [int , int ]:
210+ """Create an anonymous pipe.
211+
212+ pipe_attrs
213+ Ignored internally, can be None.
214+
215+ Returns a 2-tuple of handles, to the read and write ends of the pipe.
216+ """
208217 def CreateProcess (
209218 application_name : str | None ,
210219 command_line : str | None ,
@@ -216,7 +225,19 @@ if sys.platform == "win32":
216225 current_directory : str | None ,
217226 startup_info : Any ,
218227 / ,
219- ) -> tuple [int , int , int , int ]: ...
228+ ) -> tuple [int , int , int , int ]:
229+ """Create a new process and its primary thread.
230+
231+ command_line
232+ Can be str or None
233+ proc_attrs
234+ Ignored internally, can be None.
235+ thread_attrs
236+ Ignored internally, can be None.
237+
238+ The return value is a tuple of the process handle, thread handle,
239+ process ID, and thread ID.
240+ """
220241 def DuplicateHandle (
221242 source_process_handle : int ,
222243 source_handle : int ,
@@ -225,16 +246,46 @@ if sys.platform == "win32":
225246 inherit_handle : bool ,
226247 options : int = 0 ,
227248 / ,
228- ) -> int : ...
249+ ) -> int :
250+ """Return a duplicate handle object.
251+
252+ The duplicate handle refers to the same object as the original
253+ handle. Therefore, any changes to the object are reflected
254+ through both handles.
255+ """
229256 def ExitProcess (ExitCode : int , / ) -> NoReturn : ...
230- def GetACP () -> int : ...
257+ def GetACP () -> int :
258+ """Get the current Windows ANSI code page identifier.
259+ """
231260 def GetFileType (handle : int ) -> int : ...
232- def GetCurrentProcess () -> int : ...
233- def GetExitCodeProcess (process : int , / ) -> int : ...
261+ def GetCurrentProcess () -> int :
262+ """Return a handle object for the current process.
263+ """
264+ def GetExitCodeProcess (process : int , / ) -> int :
265+ """Return the termination status of the specified process.
266+ """
234267 def GetLastError () -> int : ...
235- def GetModuleFileName (module_handle : int , / ) -> str : ...
236- def GetStdHandle (std_handle : int , / ) -> int : ...
237- def GetVersion () -> int : ...
268+ def GetModuleFileName (module_handle : int , / ) -> str :
269+ """Return the fully-qualified path for the file that contains module.
270+
271+ The module must have been loaded by the current process.
272+
273+ The module parameter should be a handle to the loaded module
274+ whose path is being requested. If this parameter is 0,
275+ GetModuleFileName retrieves the path of the executable file
276+ of the current process.
277+ """
278+ def GetStdHandle (std_handle : int , / ) -> int :
279+ """Return a handle to the specified standard device.
280+
281+ std_handle
282+ One of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE.
283+
284+ The integer associated with the handle object is returned.
285+ """
286+ def GetVersion () -> int :
287+ """Return the version number of the current operating system.
288+ """
238289 def OpenProcess (desired_access : int , inherit_handle : bool , process_id : int , / ) -> int : ...
239290 def PeekNamedPipe (handle : int , size : int = 0 , / ) -> tuple [int , int ] | tuple [bytes , int , int ]: ...
240291 if sys .version_info >= (3 , 10 ):
@@ -250,9 +301,17 @@ if sys.platform == "win32":
250301 def SetNamedPipeHandleState (
251302 named_pipe : int , mode : int | None , max_collection_count : int | None , collect_data_timeout : int | None , /
252303 ) -> None : ...
253- def TerminateProcess (handle : int , exit_code : int , / ) -> None : ...
304+ def TerminateProcess (handle : int , exit_code : int , / ) -> None :
305+ """Terminate the specified process and all of its threads.
306+ """
254307 def WaitForMultipleObjects (handle_seq : Sequence [int ], wait_flag : bool , milliseconds : int = 0xFFFFFFFF , / ) -> int : ...
255- def WaitForSingleObject (handle : int , milliseconds : int , / ) -> int : ...
308+ def WaitForSingleObject (handle : int , milliseconds : int , / ) -> int :
309+ """Wait for a single object.
310+
311+ Wait until the specified object is in the signaled state or
312+ the time-out interval elapses. The timeout value is specified
313+ in milliseconds.
314+ """
256315 def WaitNamedPipe (name : str , timeout : int , / ) -> None : ...
257316 @overload
258317 def WriteFile (handle : int , buffer : ReadableBuffer , overlapped : Literal [True ]) -> tuple [Overlapped , int ]: ...
@@ -262,6 +321,8 @@ if sys.platform == "win32":
262321 def WriteFile (handle : int , buffer : ReadableBuffer , overlapped : int | bool ) -> tuple [Any , int ]: ...
263322 @final
264323 class Overlapped :
324+ """OVERLAPPED structure wrapper
325+ """
265326 event : int
266327 def GetOverlappedResult (self , wait : bool , / ) -> tuple [int , int ]: ...
267328 def cancel (self ) -> None : ...
@@ -270,17 +331,54 @@ if sys.platform == "win32":
270331 if sys .version_info >= (3 , 13 ):
271332 def BatchedWaitForMultipleObjects (
272333 handle_seq : Sequence [int ], wait_all : bool , milliseconds : int = 0xFFFFFFFF
273- ) -> list [int ]: ...
334+ ) -> list [int ]:
335+ """Supports a larger number of handles than WaitForMultipleObjects
336+
337+ Note that the handles may be waited on other threads, which could cause
338+ issues for objects like mutexes that become associated with the thread
339+ that was waiting for them. Objects may also be left signalled, even if
340+ the wait fails.
341+
342+ It is recommended to use WaitForMultipleObjects whenever possible, and
343+ only switch to BatchedWaitForMultipleObjects for scenarios where you
344+ control all the handles involved, such as your own thread pool or
345+ files, and all wait objects are left unmodified by a wait (for example,
346+ manual reset events, threads, and files/pipes).
347+
348+ Overlapped handles returned from this module use manual reset events.
349+ """
274350 def CreateEventW (security_attributes : int , manual_reset : bool , initial_state : bool , name : str | None ) -> int : ...
275351 def CreateMutexW (security_attributes : int , initial_owner : bool , name : str ) -> int : ...
276- def GetLongPathName (path : str ) -> str : ...
277- def GetShortPathName (path : str ) -> str : ...
352+ def GetLongPathName (path : str ) -> str :
353+ """Return the long version of the provided path.
354+
355+ If the path is already in its long form, returns the same value.
356+
357+ The path must already be a 'str'. If the type is not known, use
358+ os.fsdecode before calling this function.
359+ """
360+ def GetShortPathName (path : str ) -> str :
361+ """Return the short version of the provided path.
362+
363+ If the path is already in its short form, returns the same value.
364+
365+ The path must already be a 'str'. If the type is not known, use
366+ os.fsdecode before calling this function.
367+ """
278368 def OpenEventW (desired_access : int , inherit_handle : bool , name : str ) -> int : ...
279369 def OpenMutexW (desired_access : int , inherit_handle : bool , name : str ) -> int : ...
280370 def ReleaseMutex (mutex : int ) -> None : ...
281371 def ResetEvent (event : int ) -> None : ...
282372 def SetEvent (event : int ) -> None : ...
283373
284374 if sys .version_info >= (3 , 12 ):
285- def CopyFile2 (existing_file_name : str , new_file_name : str , flags : int , progress_routine : int | None = None ) -> int : ...
375+ def CopyFile2 (existing_file_name : str , new_file_name : str , flags : int , progress_routine : int | None = None ) -> int :
376+ """Copies a file from one name to a new name.
377+
378+ This is implemented using the CopyFile2 API, which preserves all stat
379+ and metadata information apart from security attributes.
380+
381+ progress_routine is reserved for future use, but is currently not
382+ implemented. Its value is ignored.
383+ """
286384 def NeedCurrentDirectoryForExePath (exe_name : str , / ) -> bool : ...
0 commit comments