Mercurial > public > mercurial-scm > hg
comparison mercurial/win32.py @ 39611:f3900f4c63d4
py3: prevent the win32 ctype _fields_ from being transformed to bytes
Otherwise, any hg invocation dies with
TypeError: '_fields_' must be a sequence of (name, C type) pairs
# skip-blame just a r prefix
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 13 Sep 2018 00:42:25 -0400 |
parents | e7aa113b14f7 |
children | 255d1885c7f8 |
comparison
equal
deleted
inserted
replaced
39610:11ed2eadf937 | 39611:f3900f4c63d4 |
---|---|
54 elif ctypes.sizeof(ctypes.c_longlong) == ctypes.sizeof(ctypes.c_void_p): | 54 elif ctypes.sizeof(ctypes.c_longlong) == ctypes.sizeof(ctypes.c_void_p): |
55 _WPARAM = ctypes.c_ulonglong | 55 _WPARAM = ctypes.c_ulonglong |
56 _LPARAM = ctypes.c_longlong | 56 _LPARAM = ctypes.c_longlong |
57 | 57 |
58 class _FILETIME(ctypes.Structure): | 58 class _FILETIME(ctypes.Structure): |
59 _fields_ = [('dwLowDateTime', _DWORD), | 59 _fields_ = [(r'dwLowDateTime', _DWORD), |
60 ('dwHighDateTime', _DWORD)] | 60 (r'dwHighDateTime', _DWORD)] |
61 | 61 |
62 class _BY_HANDLE_FILE_INFORMATION(ctypes.Structure): | 62 class _BY_HANDLE_FILE_INFORMATION(ctypes.Structure): |
63 _fields_ = [('dwFileAttributes', _DWORD), | 63 _fields_ = [(r'dwFileAttributes', _DWORD), |
64 ('ftCreationTime', _FILETIME), | 64 (r'ftCreationTime', _FILETIME), |
65 ('ftLastAccessTime', _FILETIME), | 65 (r'ftLastAccessTime', _FILETIME), |
66 ('ftLastWriteTime', _FILETIME), | 66 (r'ftLastWriteTime', _FILETIME), |
67 ('dwVolumeSerialNumber', _DWORD), | 67 (r'dwVolumeSerialNumber', _DWORD), |
68 ('nFileSizeHigh', _DWORD), | 68 (r'nFileSizeHigh', _DWORD), |
69 ('nFileSizeLow', _DWORD), | 69 (r'nFileSizeLow', _DWORD), |
70 ('nNumberOfLinks', _DWORD), | 70 (r'nNumberOfLinks', _DWORD), |
71 ('nFileIndexHigh', _DWORD), | 71 (r'nFileIndexHigh', _DWORD), |
72 ('nFileIndexLow', _DWORD)] | 72 (r'nFileIndexLow', _DWORD)] |
73 | 73 |
74 # CreateFile | 74 # CreateFile |
75 _FILE_SHARE_READ = 0x00000001 | 75 _FILE_SHARE_READ = 0x00000001 |
76 _FILE_SHARE_WRITE = 0x00000002 | 76 _FILE_SHARE_WRITE = 0x00000002 |
77 _FILE_SHARE_DELETE = 0x00000004 | 77 _FILE_SHARE_DELETE = 0x00000004 |
89 | 89 |
90 # GetExitCodeProcess | 90 # GetExitCodeProcess |
91 _STILL_ACTIVE = 259 | 91 _STILL_ACTIVE = 259 |
92 | 92 |
93 class _STARTUPINFO(ctypes.Structure): | 93 class _STARTUPINFO(ctypes.Structure): |
94 _fields_ = [('cb', _DWORD), | 94 _fields_ = [(r'cb', _DWORD), |
95 ('lpReserved', _LPSTR), | 95 (r'lpReserved', _LPSTR), |
96 ('lpDesktop', _LPSTR), | 96 (r'lpDesktop', _LPSTR), |
97 ('lpTitle', _LPSTR), | 97 (r'lpTitle', _LPSTR), |
98 ('dwX', _DWORD), | 98 (r'dwX', _DWORD), |
99 ('dwY', _DWORD), | 99 (r'dwY', _DWORD), |
100 ('dwXSize', _DWORD), | 100 (r'dwXSize', _DWORD), |
101 ('dwYSize', _DWORD), | 101 (r'dwYSize', _DWORD), |
102 ('dwXCountChars', _DWORD), | 102 (r'dwXCountChars', _DWORD), |
103 ('dwYCountChars', _DWORD), | 103 (r'dwYCountChars', _DWORD), |
104 ('dwFillAttribute', _DWORD), | 104 (r'dwFillAttribute', _DWORD), |
105 ('dwFlags', _DWORD), | 105 (r'dwFlags', _DWORD), |
106 ('wShowWindow', _WORD), | 106 (r'wShowWindow', _WORD), |
107 ('cbReserved2', _WORD), | 107 (r'cbReserved2', _WORD), |
108 ('lpReserved2', ctypes.c_char_p), | 108 (r'lpReserved2', ctypes.c_char_p), |
109 ('hStdInput', _HANDLE), | 109 (r'hStdInput', _HANDLE), |
110 ('hStdOutput', _HANDLE), | 110 (r'hStdOutput', _HANDLE), |
111 ('hStdError', _HANDLE)] | 111 (r'hStdError', _HANDLE)] |
112 | 112 |
113 class _PROCESS_INFORMATION(ctypes.Structure): | 113 class _PROCESS_INFORMATION(ctypes.Structure): |
114 _fields_ = [('hProcess', _HANDLE), | 114 _fields_ = [(r'hProcess', _HANDLE), |
115 ('hThread', _HANDLE), | 115 (r'hThread', _HANDLE), |
116 ('dwProcessId', _DWORD), | 116 (r'dwProcessId', _DWORD), |
117 ('dwThreadId', _DWORD)] | 117 (r'dwThreadId', _DWORD)] |
118 | 118 |
119 _CREATE_NO_WINDOW = 0x08000000 | 119 _CREATE_NO_WINDOW = 0x08000000 |
120 _SW_HIDE = 0 | 120 _SW_HIDE = 0 |
121 | 121 |
122 class _COORD(ctypes.Structure): | 122 class _COORD(ctypes.Structure): |
123 _fields_ = [('X', ctypes.c_short), | 123 _fields_ = [(r'X', ctypes.c_short), |
124 ('Y', ctypes.c_short)] | 124 (r'Y', ctypes.c_short)] |
125 | 125 |
126 class _SMALL_RECT(ctypes.Structure): | 126 class _SMALL_RECT(ctypes.Structure): |
127 _fields_ = [('Left', ctypes.c_short), | 127 _fields_ = [(r'Left', ctypes.c_short), |
128 ('Top', ctypes.c_short), | 128 (r'Top', ctypes.c_short), |
129 ('Right', ctypes.c_short), | 129 (r'Right', ctypes.c_short), |
130 ('Bottom', ctypes.c_short)] | 130 (r'Bottom', ctypes.c_short)] |
131 | 131 |
132 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): | 132 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): |
133 _fields_ = [('dwSize', _COORD), | 133 _fields_ = [(r'dwSize', _COORD), |
134 ('dwCursorPosition', _COORD), | 134 (r'dwCursorPosition', _COORD), |
135 ('wAttributes', _WORD), | 135 (r'wAttributes', _WORD), |
136 ('srWindow', _SMALL_RECT), | 136 (r'srWindow', _SMALL_RECT), |
137 ('dwMaximumWindowSize', _COORD)] | 137 (r'dwMaximumWindowSize', _COORD)] |
138 | 138 |
139 _STD_OUTPUT_HANDLE = _DWORD(-11).value | 139 _STD_OUTPUT_HANDLE = _DWORD(-11).value |
140 _STD_ERROR_HANDLE = _DWORD(-12).value | 140 _STD_ERROR_HANDLE = _DWORD(-12).value |
141 | 141 |
142 # CERT_TRUST_STATUS dwErrorStatus | 142 # CERT_TRUST_STATUS dwErrorStatus |
147 PKCS_7_ASN_ENCODING = 0x00010000 | 147 PKCS_7_ASN_ENCODING = 0x00010000 |
148 | 148 |
149 # These structs are only complete enough to achieve what we need. | 149 # These structs are only complete enough to achieve what we need. |
150 class CERT_CHAIN_CONTEXT(ctypes.Structure): | 150 class CERT_CHAIN_CONTEXT(ctypes.Structure): |
151 _fields_ = ( | 151 _fields_ = ( |
152 ("cbSize", _DWORD), | 152 (r"cbSize", _DWORD), |
153 | 153 |
154 # CERT_TRUST_STATUS struct | 154 # CERT_TRUST_STATUS struct |
155 ("dwErrorStatus", _DWORD), | 155 (r"dwErrorStatus", _DWORD), |
156 ("dwInfoStatus", _DWORD), | 156 (r"dwInfoStatus", _DWORD), |
157 | 157 |
158 ("cChain", _DWORD), | 158 (r"cChain", _DWORD), |
159 ("rgpChain", ctypes.c_void_p), | 159 (r"rgpChain", ctypes.c_void_p), |
160 ("cLowerQualityChainContext", _DWORD), | 160 (r"cLowerQualityChainContext", _DWORD), |
161 ("rgpLowerQualityChainContext", ctypes.c_void_p), | 161 (r"rgpLowerQualityChainContext", ctypes.c_void_p), |
162 ("fHasRevocationFreshnessTime", _BOOL), | 162 (r"fHasRevocationFreshnessTime", _BOOL), |
163 ("dwRevocationFreshnessTime", _DWORD), | 163 (r"dwRevocationFreshnessTime", _DWORD), |
164 ) | 164 ) |
165 | 165 |
166 class CERT_USAGE_MATCH(ctypes.Structure): | 166 class CERT_USAGE_MATCH(ctypes.Structure): |
167 _fields_ = ( | 167 _fields_ = ( |
168 ("dwType", _DWORD), | 168 (r"dwType", _DWORD), |
169 | 169 |
170 # CERT_ENHKEY_USAGE struct | 170 # CERT_ENHKEY_USAGE struct |
171 ("cUsageIdentifier", _DWORD), | 171 (r"cUsageIdentifier", _DWORD), |
172 ("rgpszUsageIdentifier", ctypes.c_void_p), # LPSTR * | 172 (r"rgpszUsageIdentifier", ctypes.c_void_p), # LPSTR * |
173 ) | 173 ) |
174 | 174 |
175 class CERT_CHAIN_PARA(ctypes.Structure): | 175 class CERT_CHAIN_PARA(ctypes.Structure): |
176 _fields_ = ( | 176 _fields_ = ( |
177 ("cbSize", _DWORD), | 177 (r"cbSize", _DWORD), |
178 ("RequestedUsage", CERT_USAGE_MATCH), | 178 (r"RequestedUsage", CERT_USAGE_MATCH), |
179 ("RequestedIssuancePolicy", CERT_USAGE_MATCH), | 179 (r"RequestedIssuancePolicy", CERT_USAGE_MATCH), |
180 ("dwUrlRetrievalTimeout", _DWORD), | 180 (r"dwUrlRetrievalTimeout", _DWORD), |
181 ("fCheckRevocationFreshnessTime", _BOOL), | 181 (r"fCheckRevocationFreshnessTime", _BOOL), |
182 ("dwRevocationFreshnessTime", _DWORD), | 182 (r"dwRevocationFreshnessTime", _DWORD), |
183 ("pftCacheResync", ctypes.c_void_p), # LPFILETIME | 183 (r"pftCacheResync", ctypes.c_void_p), # LPFILETIME |
184 ("pStrongSignPara", ctypes.c_void_p), # PCCERT_STRONG_SIGN_PARA | 184 (r"pStrongSignPara", ctypes.c_void_p), # PCCERT_STRONG_SIGN_PARA |
185 ("dwStrongSignFlags", _DWORD), | 185 (r"dwStrongSignFlags", _DWORD), |
186 ) | 186 ) |
187 | 187 |
188 # types of parameters of C functions used (required by pypy) | 188 # types of parameters of C functions used (required by pypy) |
189 | 189 |
190 _crypt32.CertCreateCertificateContext.argtypes = [_DWORD, # cert encoding | 190 _crypt32.CertCreateCertificateContext.argtypes = [_DWORD, # cert encoding |