Skip to content

Commit 34355c0

Browse files
committed
Leave _pyrepl unchanged
_pyrepl is tested by mypy which doesn't know yet about @ctypes.util.struct.
1 parent 4e52388 commit 34355c0

1 file changed

Lines changed: 33 additions & 32 deletions

File tree

Lib/_pyrepl/windows_console.py

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import os
2424
import sys
2525

26-
import ctypes.util
26+
import ctypes
2727
import types
2828
from dataclasses import dataclass
2929
from ctypes.wintypes import (
@@ -37,7 +37,7 @@
3737
WCHAR,
3838
SHORT,
3939
)
40-
from ctypes import POINTER, Union
40+
from ctypes import Structure, POINTER, Union
4141
from typing import TYPE_CHECKING
4242

4343
from _colorize import ANSIColors
@@ -723,25 +723,28 @@ def repaint(self) -> None:
723723

724724

725725
# Windows interop
726-
@ctypes.util.struct
727-
class CONSOLE_SCREEN_BUFFER_INFO:
728-
dwSize: _COORD
729-
dwCursorPosition: _COORD
730-
wAttributes: WORD
731-
srWindow: SMALL_RECT
732-
dwMaximumWindowSize: _COORD
726+
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
727+
_fields_ = [
728+
("dwSize", _COORD),
729+
("dwCursorPosition", _COORD),
730+
("wAttributes", WORD),
731+
("srWindow", SMALL_RECT),
732+
("dwMaximumWindowSize", _COORD),
733+
]
733734

734735

735-
@ctypes.util.struct
736-
class CONSOLE_CURSOR_INFO:
737-
dwSize: DWORD
738-
bVisible: BOOL
736+
class CONSOLE_CURSOR_INFO(Structure):
737+
_fields_ = [
738+
("dwSize", DWORD),
739+
("bVisible", BOOL),
740+
]
739741

740742

741-
@ctypes.util.struct
742-
class CHAR_INFO:
743-
UnicodeChar: WCHAR
744-
Attributes: WORD
743+
class CHAR_INFO(Structure):
744+
_fields_ = [
745+
("UnicodeChar", WCHAR),
746+
("Attributes", WORD),
747+
]
745748

746749

747750
class Char(Union):
@@ -751,19 +754,19 @@ class Char(Union):
751754
]
752755

753756

754-
@ctypes.util.struct
755-
class KeyEvent:
756-
bKeyDown: BOOL
757-
wRepeatCount: WORD
758-
wVirtualKeyCode: WORD
759-
wVirtualScanCode: WORD
760-
uChar: Char
761-
dwControlKeyState: DWORD
757+
class KeyEvent(ctypes.Structure):
758+
_fields_ = [
759+
("bKeyDown", BOOL),
760+
("wRepeatCount", WORD),
761+
("wVirtualKeyCode", WORD),
762+
("wVirtualScanCode", WORD),
763+
("uChar", Char),
764+
("dwControlKeyState", DWORD),
765+
]
762766

763767

764-
@ctypes.util.struct
765-
class WindowsBufferSizeEvent:
766-
dwSize: _COORD
768+
class WindowsBufferSizeEvent(ctypes.Structure):
769+
_fields_ = [("dwSize", _COORD)]
767770

768771

769772
class ConsoleEvent(ctypes.Union):
@@ -773,10 +776,8 @@ class ConsoleEvent(ctypes.Union):
773776
]
774777

775778

776-
@ctypes.util.struct
777-
class INPUT_RECORD:
778-
EventType: WORD
779-
Event: ConsoleEvent
779+
class INPUT_RECORD(Structure):
780+
_fields_ = [("EventType", WORD), ("Event", ConsoleEvent)]
780781

781782

782783
KEY_EVENT = 0x01

0 commit comments

Comments
 (0)