1use crate::object::*;
2use crate::pyport::Py_ssize_t;
3use core::ffi::{c_char, c_int};
4
5extern_libpython! {
6 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetNone")]
7 pub fn PyErr_SetNone(arg1: *mut PyObject);
8 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetObject")]
9 pub fn PyErr_SetObject(arg1: *mut PyObject, arg2: *mut PyObject);
10 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetString")]
11 pub fn PyErr_SetString(exception: *mut PyObject, string: *const c_char);
12 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_Occurred")]
13 pub fn PyErr_Occurred() -> *mut PyObject;
14 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_Clear")]
15 pub fn PyErr_Clear();
16 #[cfg_attr(Py_3_12, deprecated(note = "Use PyErr_GetRaisedException() instead."))]
17 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_Fetch")]
18 pub fn PyErr_Fetch(
19 arg1: *mut *mut PyObject,
20 arg2: *mut *mut PyObject,
21 arg3: *mut *mut PyObject,
22 );
23 #[cfg_attr(Py_3_12, deprecated(note = "Use PyErr_SetRaisedException() instead."))]
24 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_Restore")]
25 pub fn PyErr_Restore(arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject);
26 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_GetExcInfo")]
27 pub fn PyErr_GetExcInfo(
28 arg1: *mut *mut PyObject,
29 arg2: *mut *mut PyObject,
30 arg3: *mut *mut PyObject,
31 );
32 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetExcInfo")]
33 pub fn PyErr_SetExcInfo(arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject);
34 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPy_FatalError")]
35 pub fn Py_FatalError(message: *const c_char) -> !;
36 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_GivenExceptionMatches")]
37 pub fn PyErr_GivenExceptionMatches(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int;
38 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_ExceptionMatches")]
39 pub fn PyErr_ExceptionMatches(arg1: *mut PyObject) -> c_int;
40 #[cfg_attr(
41 Py_3_12,
42 deprecated(
43 note = "Use PyErr_GetRaisedException() instead, to avoid any possible de-normalization."
44 )
45 )]
46 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_NormalizeException")]
47 pub fn PyErr_NormalizeException(
48 arg1: *mut *mut PyObject,
49 arg2: *mut *mut PyObject,
50 arg3: *mut *mut PyObject,
51 );
52 #[cfg(Py_3_12)]
53 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_GetRaisedException")]
54 pub fn PyErr_GetRaisedException() -> *mut PyObject;
55 #[cfg(Py_3_12)]
56 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetRaisedException")]
57 pub fn PyErr_SetRaisedException(exc: *mut PyObject);
58 #[cfg(Py_3_11)]
59 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_GetHandledException")]
60 pub fn PyErr_GetHandledException() -> *mut PyObject;
61 #[cfg(Py_3_11)]
62 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetHandledException")]
63 pub fn PyErr_SetHandledException(exc: *mut PyObject);
64 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyException_SetTraceback")]
65 pub fn PyException_SetTraceback(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int;
66 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyException_GetTraceback")]
67 pub fn PyException_GetTraceback(arg1: *mut PyObject) -> *mut PyObject;
68 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyException_GetCause")]
69 pub fn PyException_GetCause(arg1: *mut PyObject) -> *mut PyObject;
70 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyException_SetCause")]
71 pub fn PyException_SetCause(arg1: *mut PyObject, arg2: *mut PyObject);
72 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyException_GetContext")]
73 pub fn PyException_GetContext(arg1: *mut PyObject) -> *mut PyObject;
74 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyException_SetContext")]
75 pub fn PyException_SetContext(arg1: *mut PyObject, arg2: *mut PyObject);
76
77 #[cfg(RustPython)]
78 pub fn PyExceptionClass_Check(x: *mut PyObject) -> c_int;
79 #[cfg(RustPython)]
80 pub fn PyExceptionInstance_Check(x: *mut PyObject) -> c_int;
81
82 #[cfg(PyPy)]
83 #[link_name = "PyPyExceptionInstance_Class"]
84 pub fn PyExceptionInstance_Class(x: *mut PyObject) -> *mut PyObject;
85}
86
87#[inline]
88#[cfg(not(RustPython))]
89pub unsafe fn PyExceptionClass_Check(x: *mut PyObject) -> c_int {
90 (PyType_Check(x) != 0
91 && PyType_FastSubclass(x as *mut PyTypeObject, Py_TPFLAGS_BASE_EXC_SUBCLASS) != 0)
92 as c_int
93}
94
95#[inline]
96#[cfg(not(RustPython))]
97pub unsafe fn PyExceptionInstance_Check(x: *mut PyObject) -> c_int {
98 PyType_FastSubclass(Py_TYPE(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)
99}
100
101#[inline]
102#[cfg(not(PyPy))]
103pub unsafe fn PyExceptionInstance_Class(x: *mut PyObject) -> *mut PyObject {
104 Py_TYPE(x) as *mut PyObject
105}
106
107#[cfg(PyPy)]
109pub unsafe fn PyUnicodeDecodeError_Create(
110 encoding: *const c_char,
111 object: *const c_char,
112 length: Py_ssize_t,
113 start: Py_ssize_t,
114 end: Py_ssize_t,
115 reason: *const c_char,
116) -> *mut PyObject {
117 crate::_PyObject_CallFunction_SizeT(
118 PyExc_UnicodeDecodeError,
119 c"sy#nns".as_ptr(),
120 encoding,
121 object,
122 length,
123 start,
124 end,
125 reason,
126 )
127}
128
129extern_libpython! {
130 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_BaseException")]
131 pub static mut PyExc_BaseException: *mut PyObject;
132 #[cfg(Py_3_11)]
133 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_BaseExceptionGroup")]
134 pub static mut PyExc_BaseExceptionGroup: *mut PyObject;
135 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_Exception")]
136 pub static mut PyExc_Exception: *mut PyObject;
137 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_StopAsyncIteration")]
138 pub static mut PyExc_StopAsyncIteration: *mut PyObject;
139
140 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_StopIteration")]
141 pub static mut PyExc_StopIteration: *mut PyObject;
142 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_GeneratorExit")]
143 pub static mut PyExc_GeneratorExit: *mut PyObject;
144 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ArithmeticError")]
145 pub static mut PyExc_ArithmeticError: *mut PyObject;
146 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_LookupError")]
147 pub static mut PyExc_LookupError: *mut PyObject;
148
149 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_AssertionError")]
150 pub static mut PyExc_AssertionError: *mut PyObject;
151 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_AttributeError")]
152 pub static mut PyExc_AttributeError: *mut PyObject;
153 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_BufferError")]
154 pub static mut PyExc_BufferError: *mut PyObject;
155 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_EOFError")]
156 pub static mut PyExc_EOFError: *mut PyObject;
157 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_FloatingPointError")]
158 pub static mut PyExc_FloatingPointError: *mut PyObject;
159 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_OSError")]
160 pub static mut PyExc_OSError: *mut PyObject;
161 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ImportError")]
162 pub static mut PyExc_ImportError: *mut PyObject;
163 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ModuleNotFoundError")]
164 pub static mut PyExc_ModuleNotFoundError: *mut PyObject;
165 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_IndexError")]
166 pub static mut PyExc_IndexError: *mut PyObject;
167 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_KeyError")]
168 pub static mut PyExc_KeyError: *mut PyObject;
169 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_KeyboardInterrupt")]
170 pub static mut PyExc_KeyboardInterrupt: *mut PyObject;
171 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_MemoryError")]
172 pub static mut PyExc_MemoryError: *mut PyObject;
173 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_NameError")]
174 pub static mut PyExc_NameError: *mut PyObject;
175 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_OverflowError")]
176 pub static mut PyExc_OverflowError: *mut PyObject;
177 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_RuntimeError")]
178 pub static mut PyExc_RuntimeError: *mut PyObject;
179 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_RecursionError")]
180 pub static mut PyExc_RecursionError: *mut PyObject;
181 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_NotImplementedError")]
182 pub static mut PyExc_NotImplementedError: *mut PyObject;
183 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_SyntaxError")]
184 pub static mut PyExc_SyntaxError: *mut PyObject;
185 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_IndentationError")]
186 pub static mut PyExc_IndentationError: *mut PyObject;
187 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_TabError")]
188 pub static mut PyExc_TabError: *mut PyObject;
189 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ReferenceError")]
190 pub static mut PyExc_ReferenceError: *mut PyObject;
191 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_SystemError")]
192 pub static mut PyExc_SystemError: *mut PyObject;
193 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_SystemExit")]
194 pub static mut PyExc_SystemExit: *mut PyObject;
195 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_TypeError")]
196 pub static mut PyExc_TypeError: *mut PyObject;
197 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_UnboundLocalError")]
198 pub static mut PyExc_UnboundLocalError: *mut PyObject;
199 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_UnicodeError")]
200 pub static mut PyExc_UnicodeError: *mut PyObject;
201 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_UnicodeEncodeError")]
202 pub static mut PyExc_UnicodeEncodeError: *mut PyObject;
203 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_UnicodeDecodeError")]
204 pub static mut PyExc_UnicodeDecodeError: *mut PyObject;
205 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_UnicodeTranslateError")]
206 pub static mut PyExc_UnicodeTranslateError: *mut PyObject;
207 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ValueError")]
208 pub static mut PyExc_ValueError: *mut PyObject;
209 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ZeroDivisionError")]
210 pub static mut PyExc_ZeroDivisionError: *mut PyObject;
211
212 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_BlockingIOError")]
213 pub static mut PyExc_BlockingIOError: *mut PyObject;
214 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_BrokenPipeError")]
215 pub static mut PyExc_BrokenPipeError: *mut PyObject;
216 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ChildProcessError")]
217 pub static mut PyExc_ChildProcessError: *mut PyObject;
218 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ConnectionError")]
219 pub static mut PyExc_ConnectionError: *mut PyObject;
220 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ConnectionAbortedError")]
221 pub static mut PyExc_ConnectionAbortedError: *mut PyObject;
222 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ConnectionRefusedError")]
223 pub static mut PyExc_ConnectionRefusedError: *mut PyObject;
224 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ConnectionResetError")]
225 pub static mut PyExc_ConnectionResetError: *mut PyObject;
226 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_FileExistsError")]
227 pub static mut PyExc_FileExistsError: *mut PyObject;
228 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_FileNotFoundError")]
229 pub static mut PyExc_FileNotFoundError: *mut PyObject;
230 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_InterruptedError")]
231 pub static mut PyExc_InterruptedError: *mut PyObject;
232 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_IsADirectoryError")]
233 pub static mut PyExc_IsADirectoryError: *mut PyObject;
234 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_NotADirectoryError")]
235 pub static mut PyExc_NotADirectoryError: *mut PyObject;
236 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_PermissionError")]
237 pub static mut PyExc_PermissionError: *mut PyObject;
238 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ProcessLookupError")]
239 pub static mut PyExc_ProcessLookupError: *mut PyObject;
240 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_TimeoutError")]
241 pub static mut PyExc_TimeoutError: *mut PyObject;
242
243 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_OSError")]
244 #[cfg_attr(all(PyPy, Py_3_12), link_name = "PyExc_OSError")]
245 pub static mut PyExc_EnvironmentError: *mut PyObject;
246 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_OSError")]
247 #[cfg_attr(all(PyPy, Py_3_12), link_name = "PyExc_OSError")]
248 pub static mut PyExc_IOError: *mut PyObject;
249 #[cfg(windows)]
250 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_OSError")]
251 #[cfg_attr(all(PyPy, Py_3_12), link_name = "PyExc_OSError")]
252 pub static mut PyExc_WindowsError: *mut PyObject;
253
254 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_Warning")]
256 pub static mut PyExc_Warning: *mut PyObject;
257 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_UserWarning")]
258 pub static mut PyExc_UserWarning: *mut PyObject;
259 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_DeprecationWarning")]
260 pub static mut PyExc_DeprecationWarning: *mut PyObject;
261 #[cfg_attr(
262 all(PyPy, not(Py_3_12)),
263 link_name = "PyPyExc_PendingDeprecationWarning"
264 )]
265 pub static mut PyExc_PendingDeprecationWarning: *mut PyObject;
266 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_SyntaxWarning")]
267 pub static mut PyExc_SyntaxWarning: *mut PyObject;
268 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_RuntimeWarning")]
269 pub static mut PyExc_RuntimeWarning: *mut PyObject;
270 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_FutureWarning")]
271 pub static mut PyExc_FutureWarning: *mut PyObject;
272 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ImportWarning")]
273 pub static mut PyExc_ImportWarning: *mut PyObject;
274 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_UnicodeWarning")]
275 pub static mut PyExc_UnicodeWarning: *mut PyObject;
276 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_BytesWarning")]
277 pub static mut PyExc_BytesWarning: *mut PyObject;
278 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_ResourceWarning")]
279 pub static mut PyExc_ResourceWarning: *mut PyObject;
280 #[cfg(Py_3_10)]
281 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyExc_EncodingWarning")]
282 pub static mut PyExc_EncodingWarning: *mut PyObject;
283}
284
285extern_libpython! {
286 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_BadArgument")]
287 pub fn PyErr_BadArgument() -> c_int;
288 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_NoMemory")]
289 pub fn PyErr_NoMemory() -> *mut PyObject;
290 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetFromErrno")]
291 pub fn PyErr_SetFromErrno(arg1: *mut PyObject) -> *mut PyObject;
292 #[cfg_attr(
293 all(PyPy, not(Py_3_12)),
294 link_name = "PyPyErr_SetFromErrnoWithFilenameObject"
295 )]
296 pub fn PyErr_SetFromErrnoWithFilenameObject(
297 arg1: *mut PyObject,
298 arg2: *mut PyObject,
299 ) -> *mut PyObject;
300 #[cfg_attr(
301 all(PyPy, not(Py_3_12)),
302 link_name = "PyPyErr_SetFromErrnoWithFilenameObjects"
303 )]
304 pub fn PyErr_SetFromErrnoWithFilenameObjects(
305 arg1: *mut PyObject,
306 arg2: *mut PyObject,
307 arg3: *mut PyObject,
308 ) -> *mut PyObject;
309 #[cfg_attr(
310 all(PyPy, not(Py_3_12)),
311 link_name = "PyPyErr_SetFromErrnoWithFilename"
312 )]
313 pub fn PyErr_SetFromErrnoWithFilename(
314 exc: *mut PyObject,
315 filename: *const c_char,
316 ) -> *mut PyObject;
317 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_Format")]
318 pub fn PyErr_Format(exception: *mut PyObject, format: *const c_char, ...) -> *mut PyObject;
319 pub fn PyErr_SetImportErrorSubclass(
320 arg1: *mut PyObject,
321 arg2: *mut PyObject,
322 arg3: *mut PyObject,
323 arg4: *mut PyObject,
324 ) -> *mut PyObject;
325 pub fn PyErr_SetImportError(
326 arg1: *mut PyObject,
327 arg2: *mut PyObject,
328 arg3: *mut PyObject,
329 ) -> *mut PyObject;
330 #[cfg(PyPy)]
331 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_BadInternalCall")]
332 pub fn PyErr_BadInternalCall();
333
334 #[cfg(not(PyPy))]
335 fn _PyErr_BadInternalCall(filename: *const c_char, lineno: c_int);
336}
337
338#[cfg(not(PyPy))]
339#[track_caller]
340#[inline]
341pub unsafe fn PyErr_BadInternalCall() {
342 let location = core::panic::Location::caller();
343 let filename = alloc::ffi::CString::new(location.file()).unwrap();
344 unsafe {
346 _PyErr_BadInternalCall(
347 filename.as_ptr(),
348 location.line().try_into().unwrap_or(c_int::MAX),
349 )
350 }
351}
352
353extern_libpython! {
354 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_NewException")]
355 pub fn PyErr_NewException(
356 name: *const c_char,
357 base: *mut PyObject,
358 dict: *mut PyObject,
359 ) -> *mut PyObject;
360 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_NewExceptionWithDoc")]
361 pub fn PyErr_NewExceptionWithDoc(
362 name: *const c_char,
363 doc: *const c_char,
364 base: *mut PyObject,
365 dict: *mut PyObject,
366 ) -> *mut PyObject;
367 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_WriteUnraisable")]
368 pub fn PyErr_WriteUnraisable(arg1: *mut PyObject);
369 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_CheckSignals")]
370 pub fn PyErr_CheckSignals() -> c_int;
371 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetInterrupt")]
372 pub fn PyErr_SetInterrupt();
373 #[cfg(Py_3_10)]
374 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SetInterruptEx")]
375 pub fn PyErr_SetInterruptEx(signum: c_int) -> c_int;
376 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SyntaxLocation")]
377 pub fn PyErr_SyntaxLocation(filename: *const c_char, lineno: c_int);
378 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_SyntaxLocationEx")]
379 pub fn PyErr_SyntaxLocationEx(filename: *const c_char, lineno: c_int, col_offset: c_int);
380 #[cfg_attr(all(PyPy, not(Py_3_12)), link_name = "PyPyErr_ProgramText")]
381 pub fn PyErr_ProgramText(filename: *const c_char, lineno: c_int) -> *mut PyObject;
382 #[cfg(not(PyPy))]
383 pub fn PyUnicodeDecodeError_Create(
384 encoding: *const c_char,
385 object: *const c_char,
386 length: Py_ssize_t,
387 start: Py_ssize_t,
388 end: Py_ssize_t,
389 reason: *const c_char,
390 ) -> *mut PyObject;
391 pub fn PyUnicodeEncodeError_GetEncoding(arg1: *mut PyObject) -> *mut PyObject;
392 pub fn PyUnicodeDecodeError_GetEncoding(arg1: *mut PyObject) -> *mut PyObject;
393 pub fn PyUnicodeEncodeError_GetObject(arg1: *mut PyObject) -> *mut PyObject;
394 pub fn PyUnicodeDecodeError_GetObject(arg1: *mut PyObject) -> *mut PyObject;
395 pub fn PyUnicodeTranslateError_GetObject(arg1: *mut PyObject) -> *mut PyObject;
396 pub fn PyUnicodeEncodeError_GetStart(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int;
397 pub fn PyUnicodeDecodeError_GetStart(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int;
398 pub fn PyUnicodeTranslateError_GetStart(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int;
399 pub fn PyUnicodeEncodeError_SetStart(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int;
400 pub fn PyUnicodeDecodeError_SetStart(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int;
401 pub fn PyUnicodeTranslateError_SetStart(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int;
402 pub fn PyUnicodeEncodeError_GetEnd(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int;
403 pub fn PyUnicodeDecodeError_GetEnd(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int;
404 pub fn PyUnicodeTranslateError_GetEnd(arg1: *mut PyObject, arg2: *mut Py_ssize_t) -> c_int;
405 pub fn PyUnicodeEncodeError_SetEnd(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int;
406 pub fn PyUnicodeDecodeError_SetEnd(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int;
407 pub fn PyUnicodeTranslateError_SetEnd(arg1: *mut PyObject, arg2: Py_ssize_t) -> c_int;
408 pub fn PyUnicodeEncodeError_GetReason(arg1: *mut PyObject) -> *mut PyObject;
409 pub fn PyUnicodeDecodeError_GetReason(arg1: *mut PyObject) -> *mut PyObject;
410 pub fn PyUnicodeTranslateError_GetReason(arg1: *mut PyObject) -> *mut PyObject;
411 pub fn PyUnicodeEncodeError_SetReason(exc: *mut PyObject, reason: *const c_char) -> c_int;
412 pub fn PyUnicodeDecodeError_SetReason(exc: *mut PyObject, reason: *const c_char) -> c_int;
413 pub fn PyUnicodeTranslateError_SetReason(exc: *mut PyObject, reason: *const c_char) -> c_int;
414}