@ajksunkang-aios/kgraph-linux-x64 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/kgraph-launcher +15 -3
- package/lib/kgraph/scripts/build-bundle.sh +17 -4
- package/lib/site-packages/outcome/__init__.py +20 -0
- package/lib/site-packages/outcome/_impl.py +239 -0
- package/lib/site-packages/outcome/_util.py +33 -0
- package/lib/site-packages/outcome/_version.py +7 -0
- package/lib/site-packages/outcome/py.typed +0 -0
- package/lib/site-packages/outcome-1.3.0.post0.dist-info/INSTALLER +1 -0
- package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE +3 -0
- package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE.APACHE2 +202 -0
- package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE.MIT +20 -0
- package/lib/site-packages/outcome-1.3.0.post0.dist-info/METADATA +63 -0
- package/lib/site-packages/outcome-1.3.0.post0.dist-info/RECORD +13 -0
- package/lib/site-packages/outcome-1.3.0.post0.dist-info/WHEEL +6 -0
- package/lib/site-packages/outcome-1.3.0.post0.dist-info/top_level.txt +1 -0
- package/lib/site-packages/sniffio/__init__.py +17 -0
- package/lib/site-packages/sniffio/_impl.py +95 -0
- package/lib/site-packages/sniffio/_tests/__init__.py +0 -0
- package/lib/site-packages/sniffio/_tests/test_sniffio.py +84 -0
- package/lib/site-packages/sniffio/_version.py +3 -0
- package/lib/site-packages/sniffio/py.typed +0 -0
- package/lib/site-packages/sniffio-1.3.1.dist-info/INSTALLER +1 -0
- package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE +3 -0
- package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE.APACHE2 +202 -0
- package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE.MIT +20 -0
- package/lib/site-packages/sniffio-1.3.1.dist-info/METADATA +104 -0
- package/lib/site-packages/sniffio-1.3.1.dist-info/RECORD +14 -0
- package/lib/site-packages/sniffio-1.3.1.dist-info/WHEEL +5 -0
- package/lib/site-packages/sniffio-1.3.1.dist-info/top_level.txt +1 -0
- package/lib/site-packages/sortedcontainers/__init__.py +74 -0
- package/lib/site-packages/sortedcontainers/sorteddict.py +812 -0
- package/lib/site-packages/sortedcontainers/sortedlist.py +2646 -0
- package/lib/site-packages/sortedcontainers/sortedset.py +733 -0
- package/lib/site-packages/sortedcontainers-2.4.0.dist-info/INSTALLER +1 -0
- package/lib/site-packages/sortedcontainers-2.4.0.dist-info/LICENSE +13 -0
- package/lib/site-packages/sortedcontainers-2.4.0.dist-info/METADATA +264 -0
- package/lib/site-packages/sortedcontainers-2.4.0.dist-info/RECORD +10 -0
- package/lib/site-packages/sortedcontainers-2.4.0.dist-info/WHEEL +6 -0
- package/lib/site-packages/sortedcontainers-2.4.0.dist-info/top_level.txt +1 -0
- package/lib/site-packages/trio/__init__.py +133 -0
- package/lib/site-packages/trio/__main__.py +3 -0
- package/lib/site-packages/trio/_abc.py +714 -0
- package/lib/site-packages/trio/_channel.py +610 -0
- package/lib/site-packages/trio/_core/__init__.py +94 -0
- package/lib/site-packages/trio/_core/_asyncgens.py +243 -0
- package/lib/site-packages/trio/_core/_concat_tb.py +26 -0
- package/lib/site-packages/trio/_core/_entry_queue.py +223 -0
- package/lib/site-packages/trio/_core/_exceptions.py +169 -0
- package/lib/site-packages/trio/_core/_generated_instrumentation.py +50 -0
- package/lib/site-packages/trio/_core/_generated_io_epoll.py +98 -0
- package/lib/site-packages/trio/_core/_generated_io_kqueue.py +153 -0
- package/lib/site-packages/trio/_core/_generated_io_windows.py +204 -0
- package/lib/site-packages/trio/_core/_generated_run.py +269 -0
- package/lib/site-packages/trio/_core/_generated_windows_ffi.py +10 -0
- package/lib/site-packages/trio/_core/_instrumentation.py +117 -0
- package/lib/site-packages/trio/_core/_io_common.py +31 -0
- package/lib/site-packages/trio/_core/_io_epoll.py +385 -0
- package/lib/site-packages/trio/_core/_io_kqueue.py +292 -0
- package/lib/site-packages/trio/_core/_io_windows.py +1036 -0
- package/lib/site-packages/trio/_core/_ki.py +271 -0
- package/lib/site-packages/trio/_core/_local.py +104 -0
- package/lib/site-packages/trio/_core/_mock_clock.py +165 -0
- package/lib/site-packages/trio/_core/_parking_lot.py +317 -0
- package/lib/site-packages/trio/_core/_run.py +3148 -0
- package/lib/site-packages/trio/_core/_run_context.py +15 -0
- package/lib/site-packages/trio/_core/_tests/__init__.py +0 -0
- package/lib/site-packages/trio/_core/_tests/test_asyncgen.py +339 -0
- package/lib/site-packages/trio/_core/_tests/test_cancelled.py +222 -0
- package/lib/site-packages/trio/_core/_tests/test_exceptiongroup_gc.py +103 -0
- package/lib/site-packages/trio/_core/_tests/test_guest_mode.py +755 -0
- package/lib/site-packages/trio/_core/_tests/test_instrumentation.py +315 -0
- package/lib/site-packages/trio/_core/_tests/test_io.py +522 -0
- package/lib/site-packages/trio/_core/_tests/test_ki.py +703 -0
- package/lib/site-packages/trio/_core/_tests/test_local.py +118 -0
- package/lib/site-packages/trio/_core/_tests/test_mock_clock.py +193 -0
- package/lib/site-packages/trio/_core/_tests/test_parking_lot.py +389 -0
- package/lib/site-packages/trio/_core/_tests/test_run.py +3024 -0
- package/lib/site-packages/trio/_core/_tests/test_thread_cache.py +227 -0
- package/lib/site-packages/trio/_core/_tests/test_tutil.py +13 -0
- package/lib/site-packages/trio/_core/_tests/test_unbounded_queue.py +154 -0
- package/lib/site-packages/trio/_core/_tests/test_windows.py +305 -0
- package/lib/site-packages/trio/_core/_tests/tutil.py +117 -0
- package/lib/site-packages/trio/_core/_tests/type_tests/nursery_start.py +79 -0
- package/lib/site-packages/trio/_core/_tests/type_tests/run.py +51 -0
- package/lib/site-packages/trio/_core/_thread_cache.py +317 -0
- package/lib/site-packages/trio/_core/_traps.py +318 -0
- package/lib/site-packages/trio/_core/_unbounded_queue.py +163 -0
- package/lib/site-packages/trio/_core/_wakeup_socketpair.py +75 -0
- package/lib/site-packages/trio/_core/_windows_cffi.py +313 -0
- package/lib/site-packages/trio/_deprecate.py +171 -0
- package/lib/site-packages/trio/_dtls.py +1380 -0
- package/lib/site-packages/trio/_file_io.py +513 -0
- package/lib/site-packages/trio/_highlevel_generic.py +125 -0
- package/lib/site-packages/trio/_highlevel_open_tcp_listeners.py +251 -0
- package/lib/site-packages/trio/_highlevel_open_tcp_stream.py +397 -0
- package/lib/site-packages/trio/_highlevel_open_unix_stream.py +65 -0
- package/lib/site-packages/trio/_highlevel_serve_listeners.py +148 -0
- package/lib/site-packages/trio/_highlevel_socket.py +423 -0
- package/lib/site-packages/trio/_highlevel_ssl_helpers.py +180 -0
- package/lib/site-packages/trio/_path.py +289 -0
- package/lib/site-packages/trio/_repl.py +159 -0
- package/lib/site-packages/trio/_signals.py +185 -0
- package/lib/site-packages/trio/_socket.py +1326 -0
- package/lib/site-packages/trio/_ssl.py +964 -0
- package/lib/site-packages/trio/_subprocess.py +1178 -0
- package/lib/site-packages/trio/_subprocess_platform/__init__.py +123 -0
- package/lib/site-packages/trio/_subprocess_platform/kqueue.py +48 -0
- package/lib/site-packages/trio/_subprocess_platform/waitid.py +113 -0
- package/lib/site-packages/trio/_subprocess_platform/windows.py +11 -0
- package/lib/site-packages/trio/_sync.py +908 -0
- package/lib/site-packages/trio/_tests/__init__.py +0 -0
- package/lib/site-packages/trio/_tests/astrill-codesigning-cert.cer +0 -0
- package/lib/site-packages/trio/_tests/check_type_completeness.py +247 -0
- package/lib/site-packages/trio/_tests/module_with_deprecations.py +22 -0
- package/lib/site-packages/trio/_tests/pytest_plugin.py +54 -0
- package/lib/site-packages/trio/_tests/test_abc.py +72 -0
- package/lib/site-packages/trio/_tests/test_channel.py +750 -0
- package/lib/site-packages/trio/_tests/test_contextvars.py +56 -0
- package/lib/site-packages/trio/_tests/test_deprecate.py +277 -0
- package/lib/site-packages/trio/_tests/test_deprecate_strict_exception_groups_false.py +64 -0
- package/lib/site-packages/trio/_tests/test_dtls.py +950 -0
- package/lib/site-packages/trio/_tests/test_exports.py +626 -0
- package/lib/site-packages/trio/_tests/test_fakenet.py +317 -0
- package/lib/site-packages/trio/_tests/test_file_io.py +269 -0
- package/lib/site-packages/trio/_tests/test_highlevel_generic.py +98 -0
- package/lib/site-packages/trio/_tests/test_highlevel_open_tcp_listeners.py +419 -0
- package/lib/site-packages/trio/_tests/test_highlevel_open_tcp_stream.py +693 -0
- package/lib/site-packages/trio/_tests/test_highlevel_open_unix_stream.py +86 -0
- package/lib/site-packages/trio/_tests/test_highlevel_serve_listeners.py +186 -0
- package/lib/site-packages/trio/_tests/test_highlevel_socket.py +336 -0
- package/lib/site-packages/trio/_tests/test_highlevel_ssl_helpers.py +169 -0
- package/lib/site-packages/trio/_tests/test_path.py +279 -0
- package/lib/site-packages/trio/_tests/test_repl.py +428 -0
- package/lib/site-packages/trio/_tests/test_scheduler_determinism.py +47 -0
- package/lib/site-packages/trio/_tests/test_signals.py +186 -0
- package/lib/site-packages/trio/_tests/test_socket.py +1253 -0
- package/lib/site-packages/trio/_tests/test_ssl.py +1371 -0
- package/lib/site-packages/trio/_tests/test_subprocess.py +767 -0
- package/lib/site-packages/trio/_tests/test_sync.py +735 -0
- package/lib/site-packages/trio/_tests/test_testing.py +682 -0
- package/lib/site-packages/trio/_tests/test_testing_raisesgroup.py +1128 -0
- package/lib/site-packages/trio/_tests/test_threads.py +1173 -0
- package/lib/site-packages/trio/_tests/test_timeouts.py +281 -0
- package/lib/site-packages/trio/_tests/test_tracing.py +88 -0
- package/lib/site-packages/trio/_tests/test_trio.py +8 -0
- package/lib/site-packages/trio/_tests/test_unix_pipes.py +288 -0
- package/lib/site-packages/trio/_tests/test_util.py +349 -0
- package/lib/site-packages/trio/_tests/test_wait_for_object.py +225 -0
- package/lib/site-packages/trio/_tests/test_windows_pipes.py +112 -0
- package/lib/site-packages/trio/_tests/tools/__init__.py +0 -0
- package/lib/site-packages/trio/_tests/tools/test_gen_exports.py +179 -0
- package/lib/site-packages/trio/_tests/tools/test_mypy_annotate.py +140 -0
- package/lib/site-packages/trio/_tests/tools/test_sync_requirements.py +80 -0
- package/lib/site-packages/trio/_tests/type_tests/check_wraps.py +9 -0
- package/lib/site-packages/trio/_tests/type_tests/open_memory_channel.py +4 -0
- package/lib/site-packages/trio/_tests/type_tests/path.py +140 -0
- package/lib/site-packages/trio/_tests/type_tests/subprocesses.py +23 -0
- package/lib/site-packages/trio/_tests/type_tests/task_status.py +29 -0
- package/lib/site-packages/trio/_threads.py +610 -0
- package/lib/site-packages/trio/_timeouts.py +197 -0
- package/lib/site-packages/trio/_tools/__init__.py +0 -0
- package/lib/site-packages/trio/_tools/gen_exports.py +401 -0
- package/lib/site-packages/trio/_tools/mypy_annotate.py +126 -0
- package/lib/site-packages/trio/_tools/sync_requirements.py +98 -0
- package/lib/site-packages/trio/_tools/windows_ffi_build.py +220 -0
- package/lib/site-packages/trio/_unix_pipes.py +197 -0
- package/lib/site-packages/trio/_util.py +385 -0
- package/lib/site-packages/trio/_version.py +3 -0
- package/lib/site-packages/trio/_wait_for_object.py +67 -0
- package/lib/site-packages/trio/_windows_pipes.py +144 -0
- package/lib/site-packages/trio/abc.py +23 -0
- package/lib/site-packages/trio/from_thread.py +13 -0
- package/lib/site-packages/trio/lowlevel.py +95 -0
- package/lib/site-packages/trio/py.typed +0 -0
- package/lib/site-packages/trio/socket.py +602 -0
- package/lib/site-packages/trio/testing/__init__.py +58 -0
- package/lib/site-packages/trio/testing/_check_streams.py +570 -0
- package/lib/site-packages/trio/testing/_checkpoints.py +69 -0
- package/lib/site-packages/trio/testing/_fake_net.py +584 -0
- package/lib/site-packages/trio/testing/_memory_streams.py +633 -0
- package/lib/site-packages/trio/testing/_network.py +36 -0
- package/lib/site-packages/trio/testing/_raises_group.py +1015 -0
- package/lib/site-packages/trio/testing/_sequencer.py +87 -0
- package/lib/site-packages/trio/testing/_trio_test.py +50 -0
- package/lib/site-packages/trio/to_thread.py +4 -0
- package/lib/site-packages/trio-0.33.0.dist-info/INSTALLER +1 -0
- package/lib/site-packages/trio-0.33.0.dist-info/METADATA +186 -0
- package/lib/site-packages/trio-0.33.0.dist-info/RECORD +156 -0
- package/lib/site-packages/trio-0.33.0.dist-info/REQUESTED +0 -0
- package/lib/site-packages/trio-0.33.0.dist-info/WHEEL +5 -0
- package/lib/site-packages/trio-0.33.0.dist-info/entry_points.txt +2 -0
- package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE +3 -0
- package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE.APACHE2 +202 -0
- package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE.MIT +22 -0
- package/lib/site-packages/trio-0.33.0.dist-info/top_level.txt +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import enum
|
|
4
|
+
from typing import TYPE_CHECKING, NewType, NoReturn, Protocol, TypeAlias, cast
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
import cffi
|
|
8
|
+
|
|
9
|
+
CData: TypeAlias = cffi.api.FFI.CData
|
|
10
|
+
CType: TypeAlias = cffi.api.FFI.CType
|
|
11
|
+
|
|
12
|
+
from ._generated_windows_ffi import ffi
|
|
13
|
+
|
|
14
|
+
################################################################
|
|
15
|
+
# Functions and types
|
|
16
|
+
################################################################
|
|
17
|
+
|
|
18
|
+
if not TYPE_CHECKING:
|
|
19
|
+
CData: TypeAlias = ffi.CData
|
|
20
|
+
CType: TypeAlias = ffi.CType
|
|
21
|
+
|
|
22
|
+
AlwaysNull: TypeAlias = CData # We currently always pass ffi.NULL here.
|
|
23
|
+
Handle = NewType("Handle", CData)
|
|
24
|
+
HandleArray = NewType("HandleArray", CData)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class _Kernel32(Protocol):
|
|
28
|
+
"""Statically typed version of the kernel32.dll functions we use."""
|
|
29
|
+
|
|
30
|
+
def CreateIoCompletionPort(
|
|
31
|
+
self,
|
|
32
|
+
FileHandle: Handle,
|
|
33
|
+
ExistingCompletionPort: CData | AlwaysNull,
|
|
34
|
+
CompletionKey: int,
|
|
35
|
+
NumberOfConcurrentThreads: int,
|
|
36
|
+
/,
|
|
37
|
+
) -> Handle: ...
|
|
38
|
+
|
|
39
|
+
def CreateEventA(
|
|
40
|
+
self,
|
|
41
|
+
lpEventAttributes: AlwaysNull,
|
|
42
|
+
bManualReset: bool,
|
|
43
|
+
bInitialState: bool,
|
|
44
|
+
lpName: AlwaysNull,
|
|
45
|
+
/,
|
|
46
|
+
) -> Handle: ...
|
|
47
|
+
|
|
48
|
+
def SetFileCompletionNotificationModes(
|
|
49
|
+
self,
|
|
50
|
+
handle: Handle,
|
|
51
|
+
flags: CompletionModes,
|
|
52
|
+
/,
|
|
53
|
+
) -> int: ...
|
|
54
|
+
|
|
55
|
+
def PostQueuedCompletionStatus(
|
|
56
|
+
self,
|
|
57
|
+
CompletionPort: Handle,
|
|
58
|
+
dwNumberOfBytesTransferred: int,
|
|
59
|
+
dwCompletionKey: int,
|
|
60
|
+
lpOverlapped: CData | AlwaysNull,
|
|
61
|
+
/,
|
|
62
|
+
) -> bool: ...
|
|
63
|
+
|
|
64
|
+
def CancelIoEx(
|
|
65
|
+
self,
|
|
66
|
+
hFile: Handle,
|
|
67
|
+
lpOverlapped: CData | AlwaysNull,
|
|
68
|
+
/,
|
|
69
|
+
) -> bool: ...
|
|
70
|
+
|
|
71
|
+
def WriteFile(
|
|
72
|
+
self,
|
|
73
|
+
hFile: Handle,
|
|
74
|
+
# not sure about this type
|
|
75
|
+
lpBuffer: CData,
|
|
76
|
+
nNumberOfBytesToWrite: int,
|
|
77
|
+
lpNumberOfBytesWritten: AlwaysNull,
|
|
78
|
+
lpOverlapped: _Overlapped,
|
|
79
|
+
/,
|
|
80
|
+
) -> bool: ...
|
|
81
|
+
|
|
82
|
+
def ReadFile(
|
|
83
|
+
self,
|
|
84
|
+
hFile: Handle,
|
|
85
|
+
# not sure about this type
|
|
86
|
+
lpBuffer: CData,
|
|
87
|
+
nNumberOfBytesToRead: int,
|
|
88
|
+
lpNumberOfBytesRead: AlwaysNull,
|
|
89
|
+
lpOverlapped: _Overlapped,
|
|
90
|
+
/,
|
|
91
|
+
) -> bool: ...
|
|
92
|
+
|
|
93
|
+
def GetQueuedCompletionStatusEx(
|
|
94
|
+
self,
|
|
95
|
+
CompletionPort: Handle,
|
|
96
|
+
lpCompletionPortEntries: CData,
|
|
97
|
+
ulCount: int,
|
|
98
|
+
ulNumEntriesRemoved: CData,
|
|
99
|
+
dwMilliseconds: int,
|
|
100
|
+
fAlertable: bool | int,
|
|
101
|
+
/,
|
|
102
|
+
) -> CData: ...
|
|
103
|
+
|
|
104
|
+
def CreateFileW(
|
|
105
|
+
self,
|
|
106
|
+
lpFileName: CData,
|
|
107
|
+
dwDesiredAccess: FileFlags,
|
|
108
|
+
dwShareMode: FileFlags,
|
|
109
|
+
lpSecurityAttributes: AlwaysNull,
|
|
110
|
+
dwCreationDisposition: FileFlags,
|
|
111
|
+
dwFlagsAndAttributes: FileFlags,
|
|
112
|
+
hTemplateFile: AlwaysNull,
|
|
113
|
+
/,
|
|
114
|
+
) -> Handle: ...
|
|
115
|
+
|
|
116
|
+
def WaitForSingleObject(self, hHandle: Handle, dwMilliseconds: int, /) -> CData: ...
|
|
117
|
+
|
|
118
|
+
def WaitForMultipleObjects(
|
|
119
|
+
self,
|
|
120
|
+
nCount: int,
|
|
121
|
+
lpHandles: HandleArray,
|
|
122
|
+
bWaitAll: bool,
|
|
123
|
+
dwMilliseconds: int,
|
|
124
|
+
/,
|
|
125
|
+
) -> ErrorCodes: ...
|
|
126
|
+
|
|
127
|
+
def SetEvent(self, handle: Handle, /) -> None: ...
|
|
128
|
+
|
|
129
|
+
def CloseHandle(self, handle: Handle, /) -> bool: ...
|
|
130
|
+
|
|
131
|
+
def DeviceIoControl(
|
|
132
|
+
self,
|
|
133
|
+
hDevice: Handle,
|
|
134
|
+
dwIoControlCode: int,
|
|
135
|
+
# this is wrong (it's not always null)
|
|
136
|
+
lpInBuffer: AlwaysNull,
|
|
137
|
+
nInBufferSize: int,
|
|
138
|
+
# this is also wrong
|
|
139
|
+
lpOutBuffer: AlwaysNull,
|
|
140
|
+
nOutBufferSize: int,
|
|
141
|
+
lpBytesReturned: AlwaysNull,
|
|
142
|
+
lpOverlapped: CData,
|
|
143
|
+
/,
|
|
144
|
+
) -> bool: ...
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class _Nt(Protocol):
|
|
148
|
+
"""Statically typed version of the dtdll.dll functions we use."""
|
|
149
|
+
|
|
150
|
+
def RtlNtStatusToDosError(self, status: int, /) -> ErrorCodes: ...
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class _Ws2(Protocol):
|
|
154
|
+
"""Statically typed version of the ws2_32.dll functions we use."""
|
|
155
|
+
|
|
156
|
+
def WSAGetLastError(self) -> int: ...
|
|
157
|
+
|
|
158
|
+
def WSAIoctl(
|
|
159
|
+
self,
|
|
160
|
+
socket: CData,
|
|
161
|
+
dwIoControlCode: WSAIoctls,
|
|
162
|
+
lpvInBuffer: AlwaysNull,
|
|
163
|
+
cbInBuffer: int,
|
|
164
|
+
lpvOutBuffer: CData,
|
|
165
|
+
cbOutBuffer: int,
|
|
166
|
+
lpcbBytesReturned: CData, # int*
|
|
167
|
+
lpOverlapped: AlwaysNull,
|
|
168
|
+
# actually LPWSAOVERLAPPED_COMPLETION_ROUTINE
|
|
169
|
+
lpCompletionRoutine: AlwaysNull,
|
|
170
|
+
/,
|
|
171
|
+
) -> int: ...
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class _DummyStruct(Protocol):
|
|
175
|
+
Offset: int
|
|
176
|
+
OffsetHigh: int
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class _DummyUnion(Protocol):
|
|
180
|
+
DUMMYSTRUCTNAME: _DummyStruct
|
|
181
|
+
Pointer: object
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class _Overlapped(Protocol):
|
|
185
|
+
Internal: int
|
|
186
|
+
InternalHigh: int
|
|
187
|
+
DUMMYUNIONNAME: _DummyUnion
|
|
188
|
+
hEvent: Handle
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
kernel32 = cast("_Kernel32", ffi.dlopen("kernel32.dll"))
|
|
192
|
+
ntdll = cast("_Nt", ffi.dlopen("ntdll.dll"))
|
|
193
|
+
ws2_32 = cast("_Ws2", ffi.dlopen("ws2_32.dll"))
|
|
194
|
+
|
|
195
|
+
################################################################
|
|
196
|
+
# Magic numbers
|
|
197
|
+
################################################################
|
|
198
|
+
|
|
199
|
+
# Here's a great resource for looking these up:
|
|
200
|
+
# https://www.magnumdb.com
|
|
201
|
+
# (Tip: check the box to see "Hex value")
|
|
202
|
+
|
|
203
|
+
INVALID_HANDLE_VALUE = Handle(ffi.cast("HANDLE", -1))
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class ErrorCodes(enum.IntEnum):
|
|
207
|
+
STATUS_TIMEOUT = 0x102
|
|
208
|
+
WAIT_TIMEOUT = 0x102
|
|
209
|
+
WAIT_ABANDONED = 0x80
|
|
210
|
+
WAIT_OBJECT_0 = 0x00 # object is signaled
|
|
211
|
+
WAIT_FAILED = 0xFFFFFFFF
|
|
212
|
+
ERROR_IO_PENDING = 997
|
|
213
|
+
ERROR_OPERATION_ABORTED = 995
|
|
214
|
+
ERROR_ABANDONED_WAIT_0 = 735
|
|
215
|
+
ERROR_INVALID_HANDLE = 6
|
|
216
|
+
ERROR_INVALID_PARAMETER = 87
|
|
217
|
+
ERROR_NOT_FOUND = 1168
|
|
218
|
+
ERROR_NOT_SOCKET = 10038
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class FileFlags(enum.IntFlag):
|
|
222
|
+
GENERIC_READ = 0x80000000
|
|
223
|
+
SYNCHRONIZE = 0x00100000
|
|
224
|
+
FILE_FLAG_OVERLAPPED = 0x40000000
|
|
225
|
+
FILE_SHARE_READ = 1
|
|
226
|
+
FILE_SHARE_WRITE = 2
|
|
227
|
+
FILE_SHARE_DELETE = 4
|
|
228
|
+
CREATE_NEW = 1
|
|
229
|
+
CREATE_ALWAYS = 2
|
|
230
|
+
OPEN_EXISTING = 3
|
|
231
|
+
OPEN_ALWAYS = 4
|
|
232
|
+
TRUNCATE_EXISTING = 5
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class AFDPollFlags(enum.IntFlag):
|
|
236
|
+
# These are drawn from a combination of:
|
|
237
|
+
# https://github.com/piscisaureus/wepoll/blob/master/src/afd.h
|
|
238
|
+
# https://github.com/reactos/reactos/blob/master/sdk/include/reactos/drivers/afd/shared.h
|
|
239
|
+
AFD_POLL_RECEIVE = 0x0001
|
|
240
|
+
AFD_POLL_RECEIVE_EXPEDITED = 0x0002 # OOB/urgent data
|
|
241
|
+
AFD_POLL_SEND = 0x0004
|
|
242
|
+
AFD_POLL_DISCONNECT = 0x0008 # received EOF (FIN)
|
|
243
|
+
AFD_POLL_ABORT = 0x0010 # received RST
|
|
244
|
+
AFD_POLL_LOCAL_CLOSE = 0x0020 # local socket object closed
|
|
245
|
+
AFD_POLL_CONNECT = 0x0040 # socket is successfully connected
|
|
246
|
+
AFD_POLL_ACCEPT = 0x0080 # you can call accept on this socket
|
|
247
|
+
AFD_POLL_CONNECT_FAIL = 0x0100 # connect() terminated unsuccessfully
|
|
248
|
+
# See WSAEventSelect docs for more details on these four:
|
|
249
|
+
AFD_POLL_QOS = 0x0200
|
|
250
|
+
AFD_POLL_GROUP_QOS = 0x0400
|
|
251
|
+
AFD_POLL_ROUTING_INTERFACE_CHANGE = 0x0800
|
|
252
|
+
AFD_POLL_EVENT_ADDRESS_LIST_CHANGE = 0x1000
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class WSAIoctls(enum.IntEnum):
|
|
256
|
+
SIO_BASE_HANDLE = 0x48000022
|
|
257
|
+
SIO_BSP_HANDLE_SELECT = 0x4800001C
|
|
258
|
+
SIO_BSP_HANDLE_POLL = 0x4800001D
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class CompletionModes(enum.IntFlag):
|
|
262
|
+
FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 0x1
|
|
263
|
+
FILE_SKIP_SET_EVENT_ON_HANDLE = 0x2
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class IoControlCodes(enum.IntEnum):
|
|
267
|
+
IOCTL_AFD_POLL = 0x00012024
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
################################################################
|
|
271
|
+
# Generic helpers
|
|
272
|
+
################################################################
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def _handle(obj: int | CData) -> Handle:
|
|
276
|
+
# For now, represent handles as either cffi HANDLEs or as ints. If you
|
|
277
|
+
# try to pass in a file descriptor instead, it's not going to work
|
|
278
|
+
# out. (For that msvcrt.get_osfhandle does the trick, but I don't know if
|
|
279
|
+
# we'll actually need that for anything...) For sockets this doesn't
|
|
280
|
+
# matter, Python never allocates an fd. So let's wait until we actually
|
|
281
|
+
# encounter the problem before worrying about it.
|
|
282
|
+
if isinstance(obj, int):
|
|
283
|
+
return Handle(ffi.cast("HANDLE", obj))
|
|
284
|
+
return Handle(obj)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def handle_array(count: int) -> HandleArray:
|
|
288
|
+
"""Make an array of handles."""
|
|
289
|
+
return HandleArray(ffi.new(f"HANDLE[{count}]"))
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def raise_winerror(
|
|
293
|
+
winerror: int | None = None,
|
|
294
|
+
*,
|
|
295
|
+
filename: str | None = None,
|
|
296
|
+
filename2: str | None = None,
|
|
297
|
+
) -> NoReturn:
|
|
298
|
+
# assert sys.platform == "win32" # TODO: make this work in MyPy
|
|
299
|
+
# ... in the meanwhile, ffi.getwinerror() is undefined on non-Windows, necessitating the type
|
|
300
|
+
# ignores.
|
|
301
|
+
|
|
302
|
+
if winerror is None:
|
|
303
|
+
err = ffi.getwinerror() # type: ignore[attr-defined,unused-ignore]
|
|
304
|
+
if err is None:
|
|
305
|
+
raise RuntimeError("No error set?")
|
|
306
|
+
winerror, msg = err
|
|
307
|
+
else:
|
|
308
|
+
err = ffi.getwinerror(winerror) # type: ignore[attr-defined,unused-ignore]
|
|
309
|
+
if err is None:
|
|
310
|
+
raise RuntimeError("No error set?")
|
|
311
|
+
_, msg = err
|
|
312
|
+
# https://docs.python.org/3/library/exceptions.html#OSError
|
|
313
|
+
raise OSError(0, msg, filename, winerror, filename2)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import warnings
|
|
5
|
+
from functools import wraps
|
|
6
|
+
from typing import TYPE_CHECKING, ClassVar, TypeVar
|
|
7
|
+
|
|
8
|
+
import attrs
|
|
9
|
+
|
|
10
|
+
from ._util import final
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from collections.abc import Callable
|
|
14
|
+
|
|
15
|
+
from typing_extensions import ParamSpec
|
|
16
|
+
|
|
17
|
+
ArgsT = ParamSpec("ArgsT")
|
|
18
|
+
|
|
19
|
+
RetT = TypeVar("RetT")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# We want our warnings to be visible by default (at least for now), but we
|
|
23
|
+
# also want it to be possible to override that using the -W switch. AFAICT
|
|
24
|
+
# this means we cannot inherit from DeprecationWarning, because the only way
|
|
25
|
+
# to make it visible by default then would be to add our own filter at import
|
|
26
|
+
# time, but that would override -W switches...
|
|
27
|
+
class TrioDeprecationWarning(FutureWarning):
|
|
28
|
+
"""Warning emitted if you use deprecated Trio functionality.
|
|
29
|
+
|
|
30
|
+
While a relatively mature project, Trio remains committed to refining its
|
|
31
|
+
design and improving usability. As part of this, we occasionally deprecate
|
|
32
|
+
or remove functionality that proves suboptimal. If you use Trio, we
|
|
33
|
+
recommend `subscribing to issue #1
|
|
34
|
+
<https://github.com/python-trio/trio/issues/1>`__ to get information about
|
|
35
|
+
upcoming deprecations and other backwards compatibility breaking changes.
|
|
36
|
+
|
|
37
|
+
Despite the name, this class currently inherits from
|
|
38
|
+
:class:`FutureWarning`, not :class:`DeprecationWarning`, because until a
|
|
39
|
+
1.0 release, we want these warnings to be visible by default. You can hide
|
|
40
|
+
them by installing a filter or with the ``-W`` switch: see the
|
|
41
|
+
:mod:`warnings` documentation for details.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _url_for_issue(issue: int) -> str:
|
|
46
|
+
return f"https://github.com/python-trio/trio/issues/{issue}"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _stringify(thing: object) -> str:
|
|
50
|
+
if hasattr(thing, "__module__") and hasattr(thing, "__qualname__"):
|
|
51
|
+
return f"{thing.__module__}.{thing.__qualname__}"
|
|
52
|
+
return str(thing)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def warn_deprecated(
|
|
56
|
+
thing: object,
|
|
57
|
+
version: str,
|
|
58
|
+
*,
|
|
59
|
+
issue: int | None,
|
|
60
|
+
instead: object,
|
|
61
|
+
stacklevel: int = 2,
|
|
62
|
+
use_triodeprecationwarning: bool = False,
|
|
63
|
+
) -> None:
|
|
64
|
+
stacklevel += 1
|
|
65
|
+
msg = f"{_stringify(thing)} is deprecated since Trio {version}"
|
|
66
|
+
if instead is None:
|
|
67
|
+
msg += " with no replacement"
|
|
68
|
+
else:
|
|
69
|
+
msg += f"; use {_stringify(instead)} instead"
|
|
70
|
+
if issue is not None:
|
|
71
|
+
msg += f" ({_url_for_issue(issue)})"
|
|
72
|
+
if use_triodeprecationwarning:
|
|
73
|
+
warning_class: type[Warning] = TrioDeprecationWarning
|
|
74
|
+
else:
|
|
75
|
+
warning_class = DeprecationWarning
|
|
76
|
+
warnings.warn(warning_class(msg), stacklevel=stacklevel)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# @deprecated("0.2.0", issue=..., instead=...)
|
|
80
|
+
# def ...
|
|
81
|
+
def deprecated(
|
|
82
|
+
version: str,
|
|
83
|
+
*,
|
|
84
|
+
thing: object = None,
|
|
85
|
+
issue: int | None,
|
|
86
|
+
instead: object,
|
|
87
|
+
use_triodeprecationwarning: bool = False,
|
|
88
|
+
) -> Callable[[Callable[ArgsT, RetT]], Callable[ArgsT, RetT]]:
|
|
89
|
+
def do_wrap(fn: Callable[ArgsT, RetT]) -> Callable[ArgsT, RetT]:
|
|
90
|
+
nonlocal thing
|
|
91
|
+
|
|
92
|
+
@wraps(fn)
|
|
93
|
+
def wrapper(*args: ArgsT.args, **kwargs: ArgsT.kwargs) -> RetT:
|
|
94
|
+
warn_deprecated(
|
|
95
|
+
thing,
|
|
96
|
+
version,
|
|
97
|
+
instead=instead,
|
|
98
|
+
issue=issue,
|
|
99
|
+
use_triodeprecationwarning=use_triodeprecationwarning,
|
|
100
|
+
)
|
|
101
|
+
return fn(*args, **kwargs)
|
|
102
|
+
|
|
103
|
+
# If our __module__ or __qualname__ get modified, we want to pick up
|
|
104
|
+
# on that, so we read them off the wrapper object instead of the (now
|
|
105
|
+
# hidden) fn object
|
|
106
|
+
if thing is None:
|
|
107
|
+
thing = wrapper
|
|
108
|
+
|
|
109
|
+
if wrapper.__doc__ is not None:
|
|
110
|
+
doc = wrapper.__doc__
|
|
111
|
+
doc = doc.rstrip()
|
|
112
|
+
doc += "\n\n"
|
|
113
|
+
doc += f".. deprecated:: {version}\n"
|
|
114
|
+
if instead is not None:
|
|
115
|
+
doc += f" Use {_stringify(instead)} instead.\n"
|
|
116
|
+
if issue is not None:
|
|
117
|
+
doc += f" For details, see `issue #{issue} <{_url_for_issue(issue)}>`__.\n"
|
|
118
|
+
doc += "\n"
|
|
119
|
+
wrapper.__doc__ = doc
|
|
120
|
+
|
|
121
|
+
return wrapper
|
|
122
|
+
|
|
123
|
+
return do_wrap
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def deprecated_alias(
|
|
127
|
+
old_qualname: str,
|
|
128
|
+
new_fn: Callable[ArgsT, RetT],
|
|
129
|
+
version: str,
|
|
130
|
+
*,
|
|
131
|
+
issue: int | None,
|
|
132
|
+
) -> Callable[ArgsT, RetT]:
|
|
133
|
+
@deprecated(version, issue=issue, instead=new_fn)
|
|
134
|
+
@wraps(new_fn, assigned=("__module__", "__annotations__"))
|
|
135
|
+
def wrapper(*args: ArgsT.args, **kwargs: ArgsT.kwargs) -> RetT:
|
|
136
|
+
"""Deprecated alias."""
|
|
137
|
+
return new_fn(*args, **kwargs)
|
|
138
|
+
|
|
139
|
+
wrapper.__qualname__ = old_qualname
|
|
140
|
+
wrapper.__name__ = old_qualname.rpartition(".")[-1]
|
|
141
|
+
return wrapper
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@final
|
|
145
|
+
@attrs.frozen(slots=False)
|
|
146
|
+
class DeprecatedAttribute:
|
|
147
|
+
_not_set: ClassVar[object] = object()
|
|
148
|
+
|
|
149
|
+
value: object
|
|
150
|
+
version: str
|
|
151
|
+
issue: int | None
|
|
152
|
+
instead: object = _not_set
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def deprecate_attributes(
|
|
156
|
+
module_name: str, deprecated_attributes: dict[str, DeprecatedAttribute]
|
|
157
|
+
) -> None:
|
|
158
|
+
def __getattr__(name: str) -> object:
|
|
159
|
+
if name in deprecated_attributes:
|
|
160
|
+
info = deprecated_attributes[name]
|
|
161
|
+
instead = info.instead
|
|
162
|
+
if instead is DeprecatedAttribute._not_set:
|
|
163
|
+
instead = info.value
|
|
164
|
+
thing = f"{module_name}.{name}"
|
|
165
|
+
warn_deprecated(thing, info.version, issue=info.issue, instead=instead)
|
|
166
|
+
return info.value
|
|
167
|
+
|
|
168
|
+
msg = "module '{}' has no attribute '{}'"
|
|
169
|
+
raise AttributeError(msg.format(module_name, name))
|
|
170
|
+
|
|
171
|
+
sys.modules[module_name].__getattr__ = __getattr__ # type: ignore[method-assign]
|