| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
@cpython_api([rffi.CCHARP], Py_ssize_t, error=-1) |
| 11 |
def PyBuffer_SizeFromFormat(space, format): |
| 12 |
"""Return the implied itemsize from the struct-stype |
| 13 |
format.""" |
| 14 |
raise NotImplementedError |
| 15 |
|
| 16 |
@cpython_api([rffi.INT_real, Py_ssize_t, Py_ssize_t, Py_ssize_t, lltype.Char], lltype.Void) |
| 17 |
def PyBuffer_FillContiguousStrides(space, ndim, shape, strides, itemsize, fortran): |
| 18 |
"""Fill the strides array with byte-strides of a contiguous (C-style if |
| 19 |
fortran is 'C' or Fortran-style if fortran is 'F') array of the |
| 20 |
given shape with the given number of bytes per element.""" |
| 21 |
raise NotImplementedError |
| 22 |
|
| 23 |
@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL) |
| 24 |
def PyCell_Check(space, ob): |
| 25 |
"""Return true if ob is a cell object; ob must not be NULL.""" |
| 26 |
raise NotImplementedError |
| 27 |
|
| 28 |
@cpython_api([PyObject], PyObject) |
| 29 |
def PyCell_New(space, ob): |
| 30 |
"""Create and return a new cell object containing the value ob. The parameter may |
| 31 |
be NULL.""" |
| 32 |
raise NotImplementedError |
| 33 |
|
| 34 |
@cpython_api([PyObject], PyObject) |
| 35 |
def PyCell_Get(space, cell): |
| 36 |
"""Return the contents of the cell cell.""" |
| 37 |
raise NotImplementedError |
| 38 |
|
| 39 |
@cpython_api([PyObject], PyObject) |
| 40 |
def PyCell_GET(space, cell): |
| 41 |
"""Return the contents of the cell cell, but without checking that cell is |
| 42 |
non-NULL and a cell object.""" |
| 43 |
raise NotImplementedError |
| 44 |
borrow_from() |
| 45 |
|
| 46 |
@cpython_api([PyObject, PyObject], rffi.INT_real, error=-1) |
| 47 |
def PyCell_Set(space, cell, value): |
| 48 |
"""Set the contents of the cell object cell to value. This releases the |
| 49 |
reference to any current content of the cell. value may be NULL. cell |
| 50 |
must be non-NULL; if it is not a cell object, -1 will be returned. On |
| 51 |
success, 0 will be returned.""" |
| 52 |
raise NotImplementedError |
| 53 |
|
| 54 |
@cpython_api([PyObject, PyObject], lltype.Void) |
| 55 |
def PyCell_SET(space, cell, value): |
| 56 |
"""Sets the value of the cell object cell to value. No reference counts are |
| 57 |
adjusted, and no checks are made for safety; cell must be non-NULL and must |
| 58 |
be a cell object.""" |
| 59 |
raise NotImplementedError |
| 60 |
|
| 61 |
@cpython_api([PyObject], rffi.INT_real, error=-1) |
| 62 |
def PyCodec_Register(space, search_function): |
| 63 |
"""Register a new codec search function. |
| 64 |
|
| 65 |
As side effect, this tries to load the encodings package, if not yet |
| 66 |
done, to make sure that it is always first in the list of search functions.""" |
| 67 |
raise NotImplementedError |
| 68 |
|
| 69 |
|
| 70 |
@cpython_api([rffi.CCHARP], rffi.INT_real, error=-1) |
| 71 |
def PyCodec_KnownEncoding(space, encoding): |
| 72 |
"""Return 1 or 0 depending on whether there is a registered codec for |
| 73 |
the given encoding.""" |
| 74 |
raise NotImplementedError |
| 75 |
|
| 76 |
|
| 77 |
@cpython_api([rffi.CCHARP, PyObject, rffi.CCHARP], PyObject) |
| 78 |
def PyCodec_StreamReader(space, encoding, stream, errors): |
| 79 |
"""Get a StreamReader factory function for the given encoding.""" |
| 80 |
raise NotImplementedError |
| 81 |
|
| 82 |
@cpython_api([rffi.CCHARP, PyObject, rffi.CCHARP], PyObject) |
| 83 |
def PyCodec_StreamWriter(space, encoding, stream, errors): |
| 84 |
"""Get a StreamWriter factory function for the given encoding.""" |
| 85 |
raise NotImplementedError |
| 86 |
|
| 87 |
@cpython_api([rffi.CCHARP, PyObject], rffi.INT_real, error=-1) |
| 88 |
def PyCodec_RegisterError(space, name, error): |
| 89 |
"""Register the error handling callback function error under the given name. |
| 90 |
This callback function will be called by a codec when it encounters |
| 91 |
unencodable characters/undecodable bytes and name is specified as the error |
| 92 |
parameter in the call to the encode/decode function. |
| 93 |
|
| 94 |
The callback gets a single argument, an instance of |
| 95 |
UnicodeEncodeError, UnicodeDecodeError or |
| 96 |
UnicodeTranslateError that holds information about the problematic |
| 97 |
sequence of characters or bytes and their offset in the original string (see |
| 98 |
unicodeexceptions for functions to extract this information). The |
| 99 |
callback must either raise the given exception, or return a two-item tuple |
| 100 |
containing the replacement for the problematic sequence, and an integer |
| 101 |
giving the offset in the original string at which encoding/decoding should be |
| 102 |
resumed. |
| 103 |
|
| 104 |
Return 0 on success, -1 on error.""" |
| 105 |
raise NotImplementedError |
| 106 |
|
| 107 |
@cpython_api([rffi.CCHARP], PyObject) |
| 108 |
def PyCodec_LookupError(space, name): |
| 109 |
"""Lookup the error handling callback function registered under name. As a |
| 110 |
special case NULL can be passed, in which case the error handling callback |
| 111 |
for "strict" will be returned.""" |
| 112 |
raise NotImplementedError |
| 113 |
|
| 114 |
@cpython_api([PyObject], PyObject) |
| 115 |
def PyCodec_StrictErrors(space, exc): |
| 116 |
"""Raise exc as an exception.""" |
| 117 |
raise NotImplementedError |
| 118 |
|
| 119 |
@cpython_api([PyObject], PyObject) |
| 120 |
def PyCodec_IgnoreErrors(space, exc): |
| 121 |
"""Ignore the unicode error, skipping the faulty input.""" |
| 122 |
raise NotImplementedError |
| 123 |
|
| 124 |
@cpython_api([PyObject], PyObject) |
| 125 |
def PyCodec_ReplaceErrors(space, exc): |
| 126 |
"""Replace the unicode encode error with ? or U+FFFD.""" |
| 127 |
raise NotImplementedError |
| 128 |
|
| 129 |
@cpython_api([PyObject], PyObject) |
| 130 |
def PyCodec_XMLCharRefReplaceErrors(space, exc): |
| 131 |
"""Replace the unicode encode error with XML character references.""" |
| 132 |
raise NotImplementedError |
| 133 |
|
| 134 |
@cpython_api([PyObject], PyObject) |
| 135 |
def PyCodec_BackslashReplaceErrors(space, exc): |
| 136 |
r"""Replace the unicode encode error with backslash escapes (\x, \u and |
| 137 |
\U).""" |
| 138 |
raise NotImplementedError |
| 139 |
|
| 140 |
@cpython_api([Py_complex, Py_complex], Py_complex) |
| 141 |
def _Py_c_sum(space, left, right): |
| 142 |
"""Return the sum of two complex numbers, using the C Py_complex |
| 143 |
representation.""" |
| 144 |
raise NotImplementedError |
| 145 |
|
| 146 |
@cpython_api([Py_complex, Py_complex], Py_complex) |
| 147 |
def _Py_c_diff(space, left, right): |
| 148 |
"""Return the difference between two complex numbers, using the C |
| 149 |
Py_complex representation.""" |
| 150 |
raise NotImplementedError |
| 151 |
|
| 152 |
@cpython_api([Py_complex], Py_complex) |
| 153 |
def _Py_c_neg(space, complex): |
| 154 |
"""Return the negation of the complex number complex, using the C |
| 155 |
Py_complex representation.""" |
| 156 |
raise NotImplementedError |
| 157 |
|
| 158 |
@cpython_api([Py_complex, Py_complex], Py_complex) |
| 159 |
def _Py_c_prod(space, left, right): |
| 160 |
"""Return the product of two complex numbers, using the C Py_complex |
| 161 |
representation.""" |
| 162 |
raise NotImplementedError |
| 163 |
|
| 164 |
@cpython_api([Py_complex, Py_complex], Py_complex) |
| 165 |
def _Py_c_quot(space, dividend, divisor): |
| 166 |
"""Return the quotient of two complex numbers, using the C Py_complex |
| 167 |
representation. |
| 168 |
|
| 169 |
If divisor is null, this method returns zero and sets |
| 170 |
errno to EDOM.""" |
| 171 |
raise NotImplementedError |
| 172 |
|
| 173 |
@cpython_api([Py_complex, Py_complex], Py_complex) |
| 174 |
def _Py_c_pow(space, num, exp): |
| 175 |
"""Return the exponentiation of num by exp, using the C Py_complex |
| 176 |
representation. |
| 177 |
|
| 178 |
If num is null and exp is not a positive real number, |
| 179 |
this method returns zero and sets errno to EDOM.""" |
| 180 |
raise NotImplementedError |
| 181 |
|
| 182 |
@cpython_api([rffi.CCHARP, rffi.CCHARP], rffi.CCHARP) |
| 183 |
def PyOS_stricmp(space, s1, s2): |
| 184 |
"""Case insensitive comparison of strings. The function works almost |
| 185 |
identically to strcmp() except that it ignores the case. |
| 186 |
""" |
| 187 |
raise NotImplementedError |
| 188 |
|
| 189 |
@cpython_api([rffi.CCHARP, rffi.CCHARP, Py_ssize_t], rffi.CCHARP) |
| 190 |
def PyOS_strnicmp(space, s1, s2, size): |
| 191 |
"""Case insensitive comparison of strings. The function works almost |
| 192 |
identically to strncmp() except that it ignores the case. |
| 193 |
""" |
| 194 |
raise NotImplementedError |
| 195 |
|
| 196 |
@cpython_api([PyTypeObjectPtr, PyMemberDef], PyObject) |
| 197 |
def PyDescr_NewMember(space, type, meth): |
| 198 |
raise NotImplementedError |
| 199 |
|
| 200 |
@cpython_api([PyTypeObjectPtr, wrapperbase, rffi.VOIDP], PyObject) |
| 201 |
def PyDescr_NewWrapper(space, type, wrapper, wrapped): |
| 202 |
raise NotImplementedError |
| 203 |
|
| 204 |
@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL) |
| 205 |
def PyDescr_IsData(space, descr): |
| 206 |
"""Return true if the descriptor objects descr describes a data attribute, or |
| 207 |
false if it describes a method. descr must be a descriptor object; there is |
| 208 |
no error checking. |
| 209 |
""" |
| 210 |
raise NotImplementedError |
| 211 |
|
| 212 |
@cpython_api([PyObject, PyObject], PyObject) |
| 213 |
def PyWrapper_New(space, w_d, w_self): |
| 214 |
raise NotImplementedError |
| 215 |
|
| 216 |
@cpython_api([PyObject, PyObject, rffi.INT_real], rffi.INT_real, error=-1) |
| 217 |
def PyDict_MergeFromSeq2(space, a, seq2, override): |
| 218 |
"""Update or merge into dictionary a, from the key-value pairs in seq2. |
| 219 |
seq2 must be an iterable object producing iterable objects of length 2, |
| 220 |
viewed as key-value pairs. In case of duplicate keys, the last wins if |
| 221 |
override is true, else the first wins. Return 0 on success or -1 |
| 222 |
if an exception was raised. Equivalent Python (except for the return |
| 223 |
value): |
| 224 |
|
| 225 |
def PyDict_MergeFromSeq2(a, seq2, override): |
| 226 |
for key, value in seq2: |
| 227 |
if override or key not in a: |
| 228 |
a[key] = value |
| 229 |
""" |
| 230 |
raise NotImplementedError |
| 231 |
|
| 232 |
@cpython_api([PyObject, rffi.INT_real], PyObject) |
| 233 |
def PyErr_SetExcFromWindowsErr(space, type, ierr): |
| 234 |
"""Similar to PyErr_SetFromWindowsErr(), with an additional parameter |
| 235 |
specifying the exception type to be raised. Availability: Windows. |
| 236 |
|
| 237 |
Return value: always NULL.""" |
| 238 |
raise NotImplementedError |
| 239 |
|
| 240 |
@cpython_api([rffi.INT_real, rffi.CCHARP], PyObject) |
| 241 |
def PyErr_SetFromWindowsErrWithFilename(space, ierr, filename): |
| 242 |
"""Similar to PyErr_SetFromWindowsErr(), with the additional behavior that |
| 243 |
if filename is not NULL, it is passed to the constructor of |
| 244 |
WindowsError as a third parameter. filename is decoded from the |
| 245 |
filesystem encoding (sys.getfilesystemencoding()). Availability: |
| 246 |
Windows. |
| 247 |
Return value: always NULL.""" |
| 248 |
raise NotImplementedError |
| 249 |
|
| 250 |
@cpython_api([PyObject, rffi.INT_real, rffi.CCHARP], PyObject) |
| 251 |
def PyErr_SetExcFromWindowsErrWithFilename(space, type, ierr, filename): |
| 252 |
"""Similar to PyErr_SetFromWindowsErrWithFilename(), with an additional |
| 253 |
parameter specifying the exception type to be raised. Availability: Windows. |
| 254 |
|
| 255 |
Return value: always NULL.""" |
| 256 |
raise NotImplementedError |
| 257 |
|
| 258 |
|
| 259 |
@cpython_api([rffi.CCHARP, rffi.INT_real, rffi.INT_real], lltype.Void) |
| 260 |
def PyErr_SyntaxLocationEx(space, filename, lineno, col_offset): |
| 261 |
"""Set file, line, and offset information for the current exception. If the |
| 262 |
current exception is not a SyntaxError, then it sets additional |
| 263 |
attributes, which make the exception printing subsystem think the exception |
| 264 |
is a SyntaxError. filename is decoded from the filesystem encoding |
| 265 |
(sys.getfilesystemencoding()).""" |
| 266 |
raise NotImplementedError |
| 267 |
|
| 268 |
|
| 269 |
@cpython_api([rffi.CCHARP, rffi.INT_real], lltype.Void) |
| 270 |
def PyErr_SyntaxLocation(space, filename, lineno): |
| 271 |
"""Like PyErr_SyntaxLocationExc(), but the col_offset parameter is |
| 272 |
omitted.""" |
| 273 |
raise NotImplementedError |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
@cpython_api([rffi.INT_real], rffi.INT_real, error=-1) |
| 278 |
def PySignal_SetWakeupFd(space, fd): |
| 279 |
"""This utility function specifies a file descriptor to which a '\0' byte will |
| 280 |
be written whenever a signal is received. It returns the previous such file |
| 281 |
descriptor. The value -1 disables the feature; this is the initial state. |
| 282 |
This is equivalent to signal.set_wakeup_fd() in Python, but without any |
| 283 |
error checking. fd should be a valid file descriptor. The function should |
| 284 |
only be called from the main thread.""" |
| 285 |
raise NotImplementedError |
| 286 |
|
| 287 |
@cpython_api([rffi.CCHARP, rffi.CCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject) |
| 288 |
def PyUnicodeDecodeError_Create(space, encoding, object, length, start, end, reason): |
| 289 |
"""Create a UnicodeDecodeError object with the attributes encoding, |
| 290 |
object, length, start, end and reason. encoding and reason are |
| 291 |
UTF-8 encoded strings.""" |
| 292 |
raise NotImplementedError |
| 293 |
|
| 294 |
@cpython_api([rffi.CCHARP, rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject) |
| 295 |
def PyUnicodeEncodeError_Create(space, encoding, object, length, start, end, reason): |
| 296 |
"""Create a UnicodeEncodeError object with the attributes encoding, |
| 297 |
object, length, start, end and reason. encoding and reason are |
| 298 |
UTF-8 encoded strings.""" |
| 299 |
raise NotImplementedError |
| 300 |
|
| 301 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject) |
| 302 |
def PyUnicodeTranslateError_Create(space, object, length, start, end, reason): |
| 303 |
"""Create a UnicodeTranslateError object with the attributes object, |
| 304 |
length, start, end and reason. reason is an UTF-8 encoded string.""" |
| 305 |
raise NotImplementedError |
| 306 |
|
| 307 |
@cpython_api([PyObject], PyObject) |
| 308 |
def PyUnicodeDecodeError_GetEncoding(space, exc): |
| 309 |
"""Return the encoding attribute of the given exception object.""" |
| 310 |
raise NotImplementedError |
| 311 |
|
| 312 |
@cpython_api([PyObject], PyObject) |
| 313 |
def PyUnicodeDecodeError_GetObject(space, exc): |
| 314 |
"""Return the object attribute of the given exception object.""" |
| 315 |
raise NotImplementedError |
| 316 |
|
| 317 |
@cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1) |
| 318 |
def PyUnicodeDecodeError_GetStart(space, exc, start): |
| 319 |
"""Get the start attribute of the given exception object and place it into |
| 320 |
*start. start must not be NULL. Return 0 on success, -1 on |
| 321 |
failure.""" |
| 322 |
raise NotImplementedError |
| 323 |
|
| 324 |
@cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1) |
| 325 |
def PyUnicodeDecodeError_SetStart(space, exc, start): |
| 326 |
"""Set the start attribute of the given exception object to start. Return |
| 327 |
0 on success, -1 on failure.""" |
| 328 |
raise NotImplementedError |
| 329 |
|
| 330 |
@cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1) |
| 331 |
def PyUnicodeDecodeError_GetEnd(space, exc, end): |
| 332 |
"""Get the end attribute of the given exception object and place it into |
| 333 |
*end. end must not be NULL. Return 0 on success, -1 on |
| 334 |
failure.""" |
| 335 |
raise NotImplementedError |
| 336 |
|
| 337 |
@cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1) |
| 338 |
def PyUnicodeDecodeError_SetEnd(space, exc, end): |
| 339 |
"""Set the end attribute of the given exception object to end. Return 0 |
| 340 |
on success, -1 on failure.""" |
| 341 |
raise NotImplementedError |
| 342 |
|
| 343 |
@cpython_api([PyObject], PyObject) |
| 344 |
def PyUnicodeDecodeError_GetReason(space, exc): |
| 345 |
"""Return the reason attribute of the given exception object.""" |
| 346 |
raise NotImplementedError |
| 347 |
|
| 348 |
@cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1) |
| 349 |
def PyUnicodeDecodeError_SetReason(space, exc, reason): |
| 350 |
"""Set the reason attribute of the given exception object to reason. Return |
| 351 |
0 on success, -1 on failure.""" |
| 352 |
raise NotImplementedError |
| 353 |
|
| 354 |
@cpython_api([], PyObject) |
| 355 |
def PyFloat_GetInfo(space): |
| 356 |
"""Return a structseq instance which contains information about the |
| 357 |
precision, minimum and maximum values of a float. It's a thin wrapper |
| 358 |
around the header file float.h. |
| 359 |
""" |
| 360 |
raise NotImplementedError |
| 361 |
|
| 362 |
@cpython_api([], rffi.DOUBLE, error=CANNOT_FAIL) |
| 363 |
def PyFloat_GetMax(space): |
| 364 |
"""Return the maximum representable finite float DBL_MAX as C double. |
| 365 |
""" |
| 366 |
raise NotImplementedError |
| 367 |
|
| 368 |
@cpython_api([], rffi.DOUBLE, error=CANNOT_FAIL) |
| 369 |
def PyFloat_GetMin(space): |
| 370 |
"""Return the minimum normalized positive float DBL_MIN as C double. |
| 371 |
""" |
| 372 |
raise NotImplementedError |
| 373 |
|
| 374 |
@cpython_api([], rffi.INT_real, error=-1) |
| 375 |
def PyFloat_ClearFreeList(space, ): |
| 376 |
"""Clear the float free list. Return the number of items that could not |
| 377 |
be freed. |
| 378 |
""" |
| 379 |
raise NotImplementedError |
| 380 |
|
| 381 |
@cpython_api([PyObject, PyObject], PyObject) |
| 382 |
def PyFunction_New(space, code, globals): |
| 383 |
"""Return a new function object associated with the code object code. globals |
| 384 |
must be a dictionary with the global variables accessible to the function. |
| 385 |
|
| 386 |
The function's docstring, name and __module__ are retrieved from the code |
| 387 |
object, the argument defaults and closure are set to NULL.""" |
| 388 |
raise NotImplementedError |
| 389 |
|
| 390 |
@cpython_api([PyObject], PyObject) |
| 391 |
def PyFunction_GetGlobals(space, op): |
| 392 |
"""Return the globals dictionary associated with the function object op.""" |
| 393 |
raise NotImplementedError |
| 394 |
borrow_from() |
| 395 |
|
| 396 |
@cpython_api([PyObject], PyObject) |
| 397 |
def PyFunction_GetDefaults(space, op): |
| 398 |
"""Return the argument default values of the function object op. This can be a |
| 399 |
tuple of arguments or NULL.""" |
| 400 |
raise NotImplementedError |
| 401 |
borrow_from() |
| 402 |
|
| 403 |
@cpython_api([PyObject, PyObject], rffi.INT_real, error=-1) |
| 404 |
def PyFunction_SetDefaults(space, op, defaults): |
| 405 |
"""Set the argument default values for the function object op. defaults must be |
| 406 |
Py_None or a tuple. |
| 407 |
|
| 408 |
Raises SystemError and returns -1 on failure.""" |
| 409 |
raise NotImplementedError |
| 410 |
|
| 411 |
@cpython_api([PyObject], PyObject) |
| 412 |
def PyFunction_GetClosure(space, op): |
| 413 |
"""Return the closure associated with the function object op. This can be NULL |
| 414 |
or a tuple of cell objects.""" |
| 415 |
raise NotImplementedError |
| 416 |
borrow_from() |
| 417 |
|
| 418 |
@cpython_api([PyObject, PyObject], rffi.INT_real, error=-1) |
| 419 |
def PyFunction_SetClosure(space, op, closure): |
| 420 |
"""Set the closure associated with the function object op. closure must be |
| 421 |
Py_None or a tuple of cell objects. |
| 422 |
|
| 423 |
Raises SystemError and returns -1 on failure.""" |
| 424 |
raise NotImplementedError |
| 425 |
|
| 426 |
@cpython_api([PyObject], PyObject) |
| 427 |
def PyFunction_GetAnnotations(space, op): |
| 428 |
"""Return the annotations of the function object op. This can be a |
| 429 |
mutable dictionary or NULL.""" |
| 430 |
raise NotImplementedError |
| 431 |
|
| 432 |
|
| 433 |
@cpython_api([PyObject, PyObject], rffi.INT_real, error=-1) |
| 434 |
def PyFunction_SetAnnotations(space, op, annotations): |
| 435 |
"""Set the annotations for the function object op. annotations |
| 436 |
must be a dictionary or Py_None. |
| 437 |
|
| 438 |
Raises SystemError and returns -1 on failure.""" |
| 439 |
raise NotImplementedError |
| 440 |
|
| 441 |
@cpython_api([PyObject, Py_ssize_t], PyObject) |
| 442 |
def PyObject_GC_Resize(space, op, newsize): |
| 443 |
"""Resize an object allocated by PyObject_NewVar(). Returns the |
| 444 |
resized object or NULL on failure.""" |
| 445 |
raise NotImplementedError |
| 446 |
|
| 447 |
@cpython_api([PyFrameObject], PyObject) |
| 448 |
def PyGen_New(space, frame): |
| 449 |
"""Create and return a new generator object based on the frame object. A |
| 450 |
reference to frame is stolen by this function. The parameter must not be |
| 451 |
NULL.""" |
| 452 |
raise NotImplementedError |
| 453 |
|
| 454 |
@cpython_api([rffi.CCHARP, PyObject, rffi.CCHARP, rffi.CCHARP], PyObject) |
| 455 |
def PyImport_ExecCodeModuleWithPathnames(space, name, co, pathname, cpathname): |
| 456 |
"""Like PyImport_ExecCodeModuleEx(), but the __cached__ |
| 457 |
attribute of the module object is set to cpathname if it is |
| 458 |
non-NULL. Of the three functions, this is the preferred one to use. |
| 459 |
""" |
| 460 |
raise NotImplementedError |
| 461 |
|
| 462 |
@cpython_api([], lltype.Signed, error=CANNOT_FAIL) |
| 463 |
def PyImport_GetMagicNumber(space): |
| 464 |
"""Return the magic number for Python bytecode files (a.k.a. .pyc and |
| 465 |
.pyo files). The magic number should be present in the first four bytes |
| 466 |
of the bytecode file, in little-endian byte order.""" |
| 467 |
raise NotImplementedError |
| 468 |
|
| 469 |
@cpython_api([], rffi.CCHARP) |
| 470 |
def PyImport_GetMagicTag(space, ): |
| 471 |
"""Return the magic tag string for PEP 3147 format Python bytecode file |
| 472 |
names. |
| 473 |
""" |
| 474 |
raise NotImplementedError |
| 475 |
|
| 476 |
@cpython_api([PyObject], PyObject) |
| 477 |
def PyImport_GetImporter(space, path): |
| 478 |
"""Return an importer object for a sys.path/pkg.__path__ item |
| 479 |
path, possibly by fetching it from the sys.path_importer_cache |
| 480 |
dict. If it wasn't yet cached, traverse sys.path_hooks until a hook |
| 481 |
is found that can handle the path item. Return None if no hook could; |
| 482 |
this tells our caller it should fall back to the built-in import mechanism. |
| 483 |
Cache the result in sys.path_importer_cache. Return a new reference |
| 484 |
to the importer object. |
| 485 |
""" |
| 486 |
raise NotImplementedError |
| 487 |
|
| 488 |
@cpython_api([], lltype.Void) |
| 489 |
def _PyImport_Init(space): |
| 490 |
"""Initialize the import mechanism. For internal use only.""" |
| 491 |
raise NotImplementedError |
| 492 |
|
| 493 |
@cpython_api([], lltype.Void) |
| 494 |
def PyImport_Cleanup(space): |
| 495 |
"""Empty the module table. For internal use only.""" |
| 496 |
raise NotImplementedError |
| 497 |
|
| 498 |
@cpython_api([], lltype.Void) |
| 499 |
def _PyImport_Fini(space): |
| 500 |
"""Finalize the import mechanism. For internal use only.""" |
| 501 |
raise NotImplementedError |
| 502 |
|
| 503 |
@cpython_api([rffi.CCHARP], rffi.INT_real, error=-1) |
| 504 |
def PyImport_ImportFrozenModule(space, name): |
| 505 |
"""Load a frozen module named name. Return 1 for success, 0 if the |
| 506 |
module is not found, and -1 with an exception set if the initialization |
| 507 |
failed. To access the imported module on a successful load, use |
| 508 |
PyImport_ImportModule(). (Note the misnomer --- this function would |
| 509 |
reload the module if it was already imported.)""" |
| 510 |
raise NotImplementedError |
| 511 |
|
| 512 |
@cpython_api([rffi.CCHARP, rffi.VOIDP], rffi.INT_real, error=-1) |
| 513 |
def PyImport_AppendInittab(space, name, initfunc): |
| 514 |
"""Add a single module to the existing table of built-in modules. This is a |
| 515 |
convenience wrapper around PyImport_ExtendInittab(), returning -1 if |
| 516 |
the table could not be extended. The new module can be imported by the name |
| 517 |
name, and uses the function initfunc as the initialization function called |
| 518 |
on the first attempted import. This should be called before |
| 519 |
Py_Initialize().""" |
| 520 |
raise NotImplementedError |
| 521 |
|
| 522 |
@cpython_api([_inittab], rffi.INT_real, error=-1) |
| 523 |
def PyImport_ExtendInittab(space, newtab): |
| 524 |
"""Add a collection of modules to the table of built-in modules. The newtab |
| 525 |
array must end with a sentinel entry which contains NULL for the name |
| 526 |
field; failure to provide the sentinel value can result in a memory fault. |
| 527 |
Returns 0 on success or -1 if insufficient memory could be allocated to |
| 528 |
extend the internal table. In the event of failure, no modules are added to the |
| 529 |
internal table. This should be called before Py_Initialize().""" |
| 530 |
raise NotImplementedError |
| 531 |
|
| 532 |
@cpython_api([], lltype.Void) |
| 533 |
def Py_Initialize(space, ): |
| 534 |
""" |
| 535 |
Initialize the Python interpreter. In an application embedding Python, this |
| 536 |
should be called before using any other Python/C API functions; with the |
| 537 |
exception of Py_SetProgramName(), Py_SetPythonHome() and Py_SetPath(). This initializes |
| 538 |
the table of loaded modules (sys.modules), and creates the fundamental |
| 539 |
modules builtins, __main__ and sys. It also initializes |
| 540 |
the module search path (sys.path). It does not set sys.argv; use |
| 541 |
PySys_SetArgvEx() for that. This is a no-op when called for a second time |
| 542 |
(without calling Py_Finalize() first). There is no return value; it is a |
| 543 |
fatal error if the initialization fails.""" |
| 544 |
raise NotImplementedError |
| 545 |
|
| 546 |
@cpython_api([rffi.INT_real], lltype.Void) |
| 547 |
def Py_InitializeEx(space, initsigs): |
| 548 |
"""This function works like Py_Initialize() if initsigs is 1. If |
| 549 |
initsigs is 0, it skips initialization registration of signal handlers, which |
| 550 |
might be useful when Python is embedded. |
| 551 |
""" |
| 552 |
raise NotImplementedError |
| 553 |
|
| 554 |
@cpython_api([], lltype.Void) |
| 555 |
def Py_Finalize(space): |
| 556 |
"""Undo all initializations made by Py_Initialize() and subsequent use of |
| 557 |
Python/C API functions, and destroy all sub-interpreters (see |
| 558 |
Py_NewInterpreter() below) that were created and not yet destroyed since |
| 559 |
the last call to Py_Initialize(). Ideally, this frees all memory |
| 560 |
allocated by the Python interpreter. This is a no-op when called for a second |
| 561 |
time (without calling Py_Initialize() again first). There is no return |
| 562 |
value; errors during finalization are ignored. |
| 563 |
|
| 564 |
This function is provided for a number of reasons. An embedding application |
| 565 |
might want to restart Python without having to restart the application itself. |
| 566 |
An application that has loaded the Python interpreter from a dynamically |
| 567 |
loadable library (or DLL) might want to free all memory allocated by Python |
| 568 |
before unloading the DLL. During a hunt for memory leaks in an application a |
| 569 |
developer might want to free all memory allocated by Python before exiting from |
| 570 |
the application. |
| 571 |
|
| 572 |
Bugs and caveats: The destruction of modules and objects in modules is done |
| 573 |
in random order; this may cause destructors (__del__() methods) to fail |
| 574 |
when they depend on other objects (even functions) or modules. Dynamically |
| 575 |
loaded extension modules loaded by Python are not unloaded. Small amounts of |
| 576 |
memory allocated by the Python interpreter may not be freed (if you find a leak, |
| 577 |
please report it). Memory tied up in circular references between objects is not |
| 578 |
freed. Some memory allocated by extension modules may not be freed. Some |
| 579 |
extensions may not work properly if their initialization routine is called more |
| 580 |
than once; this can happen if an application calls Py_Initialize() and |
| 581 |
Py_Finalize() more than once.""" |
| 582 |
raise NotImplementedError |
| 583 |
|
| 584 |
@cpython_api([rffi.CWCHARP], lltype.Void) |
| 585 |
def Py_SetProgramName(space, name): |
| 586 |
""" |
| 587 |
This function should be called before Py_Initialize() is called for |
| 588 |
the first time, if it is called at all. It tells the interpreter the value |
| 589 |
of the argv[0] argument to the main() function of the program |
| 590 |
(converted to wide characters). |
| 591 |
This is used by Py_GetPath() and some other functions below to find |
| 592 |
the Python run-time libraries relative to the interpreter executable. The |
| 593 |
default value is 'python'. The argument should point to a |
| 594 |
zero-terminated wide character string in static storage whose contents will not |
| 595 |
change for the duration of the program's execution. No code in the Python |
| 596 |
interpreter will change the contents of this storage.""" |
| 597 |
raise NotImplementedError |
| 598 |
|
| 599 |
@cpython_api([], rffi.CWCHARP) |
| 600 |
def Py_GetPrefix(space): |
| 601 |
"""Return the prefix for installed platform-independent files. This is derived |
| 602 |
through a number of complicated rules from the program name set with |
| 603 |
Py_SetProgramName() and some environment variables; for example, if the |
| 604 |
program name is '/usr/local/bin/python', the prefix is '/usr/local'. The |
| 605 |
returned string points into static storage; the caller should not modify its |
| 606 |
value. This corresponds to the prefix variable in the top-level |
| 607 |
Makefile and the --prefix argument to the configure |
| 608 |
script at build time. The value is available to Python code as sys.prefix. |
| 609 |
It is only useful on Unix. See also the next function.""" |
| 610 |
raise NotImplementedError |
| 611 |
|
| 612 |
@cpython_api([], rffi.CWCHARP) |
| 613 |
def Py_GetExecPrefix(space): |
| 614 |
"""Return the exec-prefix for installed platform-dependent files. This is |
| 615 |
derived through a number of complicated rules from the program name set with |
| 616 |
Py_SetProgramName() and some environment variables; for example, if the |
| 617 |
program name is '/usr/local/bin/python', the exec-prefix is |
| 618 |
'/usr/local'. The returned string points into static storage; the caller |
| 619 |
should not modify its value. This corresponds to the exec_prefix |
| 620 |
variable in the top-level Makefile and the --exec-prefix |
| 621 |
argument to the configure script at build time. The value is |
| 622 |
available to Python code as sys.exec_prefix. It is only useful on Unix. |
| 623 |
|
| 624 |
Background: The exec-prefix differs from the prefix when platform dependent |
| 625 |
files (such as executables and shared libraries) are installed in a different |
| 626 |
directory tree. In a typical installation, platform dependent files may be |
| 627 |
installed in the /usr/local/plat subtree while platform independent may |
| 628 |
be installed in /usr/local. |
| 629 |
|
| 630 |
Generally speaking, a platform is a combination of hardware and software |
| 631 |
families, e.g. Sparc machines running the Solaris 2.x operating system are |
| 632 |
considered the same platform, but Intel machines running Solaris 2.x are another |
| 633 |
platform, and Intel machines running Linux are yet another platform. Different |
| 634 |
major revisions of the same operating system generally also form different |
| 635 |
platforms. Non-Unix operating systems are a different story; the installation |
| 636 |
strategies on those systems are so different that the prefix and exec-prefix are |
| 637 |
meaningless, and set to the empty string. Note that compiled Python bytecode |
| 638 |
files are platform independent (but not independent from the Python version by |
| 639 |
which they were compiled!). |
| 640 |
|
| 641 |
System administrators will know how to configure the mount or |
| 642 |
automount programs to share /usr/local between platforms |
| 643 |
while having /usr/local/plat be a different filesystem for each |
| 644 |
platform.""" |
| 645 |
raise NotImplementedError |
| 646 |
|
| 647 |
@cpython_api([], rffi.CWCHARP) |
| 648 |
def Py_GetProgramFullPath(space): |
| 649 |
""" |
| 650 |
Return the full program name of the Python executable; this is computed as a |
| 651 |
side-effect of deriving the default module search path from the program name |
| 652 |
(set by Py_SetProgramName() above). The returned string points into |
| 653 |
static storage; the caller should not modify its value. The value is available |
| 654 |
to Python code as sys.executable.""" |
| 655 |
raise NotImplementedError |
| 656 |
|
| 657 |
@cpython_api([], rffi.CWCHARP) |
| 658 |
def Py_GetPath(space, ): |
| 659 |
""" |
| 660 |
Return the default module search path; this is computed from the program name |
| 661 |
(set by Py_SetProgramName() above) and some environment variables. |
| 662 |
The returned string consists of a series of directory names separated by a |
| 663 |
platform dependent delimiter character. The delimiter character is ':' |
| 664 |
on Unix and Mac OS X, ';' on Windows. The returned string points into |
| 665 |
static storage; the caller should not modify its value. The list |
| 666 |
sys.path is initialized with this value on interpreter startup; it |
| 667 |
can be (and usually is) modified later to change the search path for loading |
| 668 |
modules. |
| 669 |
|
| 670 |
XXX should give the exact rules""" |
| 671 |
raise NotImplementedError |
| 672 |
|
| 673 |
@cpython_api([rffi.CWCHARP], lltype.Void) |
| 674 |
def Py_SetPath(space, path): |
| 675 |
""" |
| 676 |
Set the default module search path. If this function is called before |
| 677 |
Py_Initialize(), then Py_GetPath() won't attempt to compute a |
| 678 |
default search path but uses the one provided instead. This is useful if |
| 679 |
Python is embedded by an application that has full knowledge of the location |
| 680 |
of all modules. The path components should be separated by semicolons. |
| 681 |
|
| 682 |
This also causes sys.executable to be set only to the raw program |
| 683 |
name (see Py_SetProgramName()) and for sys.prefix and |
| 684 |
sys.exec_prefix to be empty. It is up to the caller to modify these |
| 685 |
if required after calling Py_Initialize().""" |
| 686 |
raise NotImplementedError |
| 687 |
|
| 688 |
|
| 689 |
@cpython_api([], rffi.CCHARP) |
| 690 |
def Py_GetPlatform(space): |
| 691 |
""" |
| 692 |
Return the platform identifier for the current platform. On Unix, this is |
| 693 |
formed from the "official" name of the operating system, converted to lower |
| 694 |
case, followed by the major revision number; e.g., for Solaris 2.x, which is |
| 695 |
also known as SunOS 5.x, the value is 'sunos5'. On Mac OS X, it is |
| 696 |
'darwin'. On Windows, it is 'win'. The returned string points into |
| 697 |
static storage; the caller should not modify its value. The value is available |
| 698 |
to Python code as sys.platform.""" |
| 699 |
raise NotImplementedError |
| 700 |
|
| 701 |
@cpython_api([], rffi.CCHARP) |
| 702 |
def Py_GetCopyright(space): |
| 703 |
"""Return the official copyright string for the current Python version, for example |
| 704 |
|
| 705 |
'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam' |
| 706 |
|
| 707 |
The returned string points into static storage; the caller should not modify its |
| 708 |
value. The value is available to Python code as sys.copyright.""" |
| 709 |
raise NotImplementedError |
| 710 |
|
| 711 |
@cpython_api([], rffi.CCHARP) |
| 712 |
def Py_GetCompiler(space): |
| 713 |
"""Return an indication of the compiler used to build the current Python version, |
| 714 |
in square brackets, for example: |
| 715 |
|
| 716 |
"[GCC 2.7.2.2]" |
| 717 |
|
| 718 |
The returned string points into static storage; the caller should not modify its |
| 719 |
value. The value is available to Python code as part of the variable |
| 720 |
sys.version.""" |
| 721 |
raise NotImplementedError |
| 722 |
|
| 723 |
@cpython_api([], rffi.CCHARP) |
| 724 |
def Py_GetBuildInfo(space): |
| 725 |
"""Return information about the sequence number and build date and time of the |
| 726 |
current Python interpreter instance, for example |
| 727 |
|
| 728 |
"\#67, Aug 1 1997, 22:34:28" |
| 729 |
|
| 730 |
The returned string points into static storage; the caller should not modify its |
| 731 |
value. The value is available to Python code as part of the variable |
| 732 |
sys.version.""" |
| 733 |
raise NotImplementedError |
| 734 |
|
| 735 |
@cpython_api([rffi.INT_real, CWCHARPP, rffi.INT_real], lltype.Void) |
| 736 |
def PySys_SetArgvEx(space, argc, argv, updatepath): |
| 737 |
""" |
| 738 |
Set sys.argv based on argc and argv. These parameters are |
| 739 |
similar to those passed to the program's main() function with the |
| 740 |
difference that the first entry should refer to the script file to be |
| 741 |
executed rather than the executable hosting the Python interpreter. If there |
| 742 |
isn't a script that will be run, the first entry in argv can be an empty |
| 743 |
string. If this function fails to initialize sys.argv, a fatal |
| 744 |
condition is signalled using Py_FatalError(). |
| 745 |
|
| 746 |
If updatepath is zero, this is all the function does. If updatepath |
| 747 |
is non-zero, the function also modifies sys.path according to the |
| 748 |
following algorithm: |
| 749 |
|
| 750 |
If the name of an existing script is passed in argv[0], the absolute |
| 751 |
path of the directory where the script is located is prepended to |
| 752 |
sys.path. |
| 753 |
|
| 754 |
Otherwise (that is, if argc is 0 or argv[0] doesn't point |
| 755 |
to an existing file name), an empty string is prepended to |
| 756 |
sys.path, which is the same as prepending the current working |
| 757 |
directory ("."). |
| 758 |
|
| 759 |
It is recommended that applications embedding the Python interpreter |
| 760 |
for purposes other than executing a single script pass 0 as updatepath, |
| 761 |
and update sys.path themselves if desired. |
| 762 |
See CVE-2008-5983. |
| 763 |
|
| 764 |
On versions before 3.1.3, you can achieve the same effect by manually |
| 765 |
popping the first sys.path element after having called |
| 766 |
PySys_SetArgv(), for example using: |
| 767 |
|
| 768 |
PyRun_SimpleString("import sys; sys.path.pop(0)\n"); |
| 769 |
|
| 770 |
XXX impl. doesn't seem consistent in allowing 0/NULL for the params; |
| 771 |
check w/ Guido.""" |
| 772 |
raise NotImplementedError |
| 773 |
|
| 774 |
@cpython_api([rffi.INT_real, CWCHARPP], lltype.Void) |
| 775 |
def PySys_SetArgv(space, argc, argv): |
| 776 |
"""This function works like PySys_SetArgvEx() with updatepath set |
| 777 |
to 1 unless the python interpreter was started with the option -I.""" |
| 778 |
raise NotImplementedError |
| 779 |
|
| 780 |
@cpython_api([rffi.CWCHARP], lltype.Void) |
| 781 |
def Py_SetPythonHome(space, home): |
| 782 |
"""Set the default "home" directory, that is, the location of the standard |
| 783 |
Python libraries. See PYTHONHOME for the meaning of the |
| 784 |
argument string. |
| 785 |
|
| 786 |
The argument should point to a zero-terminated character string in static |
| 787 |
storage whose contents will not change for the duration of the program's |
| 788 |
execution. No code in the Python interpreter will change the contents of |
| 789 |
this storage.""" |
| 790 |
raise NotImplementedError |
| 791 |
|
| 792 |
@cpython_api([], rffi.CWCHARP) |
| 793 |
def Py_GetPythonHome(space): |
| 794 |
"""Return the default "home", that is, the value set by a previous call to |
| 795 |
Py_SetPythonHome(), or the value of the PYTHONHOME |
| 796 |
environment variable if it is set.""" |
| 797 |
raise NotImplementedError |
| 798 |
|
| 799 |
@cpython_api([], lltype.Void) |
| 800 |
def PyEval_ReInitThreads(space): |
| 801 |
"""This function is called from PyOS_AfterFork() to ensure that newly |
| 802 |
created child processes don't hold locks referring to threads which |
| 803 |
are not running in the child process.""" |
| 804 |
raise NotImplementedError |
| 805 |
|
| 806 |
@cpython_api([], PyThreadState) |
| 807 |
def PyGILState_GetThisThreadState(space, ): |
| 808 |
"""Get the current thread state for this thread. May return NULL if no |
| 809 |
GILState API has been used on the current thread. Note that the main thread |
| 810 |
always has such a thread-state, even if no auto-thread-state call has been |
| 811 |
made on the main thread. This is mainly a helper/diagnostic function.""" |
| 812 |
raise NotImplementedError |
| 813 |
|
| 814 |
|
| 815 |
@cpython_api([], PyInterpreterState) |
| 816 |
def PyInterpreterState_New(space): |
| 817 |
"""Create a new interpreter state object. The global interpreter lock need not |
| 818 |
be held, but may be held if it is necessary to serialize calls to this |
| 819 |
function.""" |
| 820 |
raise NotImplementedError |
| 821 |
|
| 822 |
@cpython_api([PyInterpreterState], lltype.Void) |
| 823 |
def PyInterpreterState_Clear(space, interp): |
| 824 |
"""Reset all information in an interpreter state object. The global interpreter |
| 825 |
lock must be held.""" |
| 826 |
raise NotImplementedError |
| 827 |
|
| 828 |
@cpython_api([PyInterpreterState], lltype.Void) |
| 829 |
def PyInterpreterState_Delete(space, interp): |
| 830 |
"""Destroy an interpreter state object. The global interpreter lock need not be |
| 831 |
held. The interpreter state must have been reset with a previous call to |
| 832 |
PyInterpreterState_Clear().""" |
| 833 |
raise NotImplementedError |
| 834 |
|
| 835 |
@cpython_api([lltype.Signed, PyObject], rffi.INT_real, error=CANNOT_FAIL) |
| 836 |
def PyThreadState_SetAsyncExc(space, id, exc): |
| 837 |
"""Asynchronously raise an exception in a thread. The id argument is the thread |
| 838 |
id of the target thread; exc is the exception object to be raised. This |
| 839 |
function does not steal any references to exc. To prevent naive misuse, you |
| 840 |
must write your own C extension to call this. Must be called with the GIL held. |
| 841 |
Returns the number of thread states modified; this is normally one, but will be |
| 842 |
zero if the thread id isn't found. If exc is NULL, the pending |
| 843 |
exception (if any) for the thread is cleared. This raises no exceptions.""" |
| 844 |
raise NotImplementedError |
| 845 |
|
| 846 |
@cpython_api([], lltype.Void) |
| 847 |
def PyEval_AcquireLock(space): |
| 848 |
"""Acquire the global interpreter lock. The lock must have been created earlier. |
| 849 |
If this thread already has the lock, a deadlock ensues. |
| 850 |
|
| 851 |
This function does not update the current thread state. Please use |
| 852 |
PyEval_RestoreThread() or PyEval_AcquireThread() |
| 853 |
instead.""" |
| 854 |
raise NotImplementedError |
| 855 |
|
| 856 |
@cpython_api([], lltype.Void) |
| 857 |
def PyEval_ReleaseLock(space): |
| 858 |
"""Release the global interpreter lock. The lock must have been created earlier. |
| 859 |
|
| 860 |
This function does not update the current thread state. Please use |
| 861 |
PyEval_SaveThread() or PyEval_ReleaseThread() |
| 862 |
instead.""" |
| 863 |
raise NotImplementedError |
| 864 |
|
| 865 |
@cpython_api([], PyThreadState) |
| 866 |
def Py_NewInterpreter(space): |
| 867 |
"""Create a new sub-interpreter. This is an (almost) totally separate |
| 868 |
environment for the execution of Python code. In particular, the new |
| 869 |
interpreter has separate, independent versions of all imported modules, |
| 870 |
including the fundamental modules builtins, __main__ and sys. The table of |
| 871 |
loaded modules (sys.modules) and the module search path (sys.path) are also |
| 872 |
separate. The new environment has no sys.argv variable. It has new standard |
| 873 |
I/O stream file objects sys.stdin, sys.stdout and sys.stderr (however these |
| 874 |
refer to the same underlying file descriptors). |
| 875 |
|
| 876 |
The return value points to the first thread state created in the new |
| 877 |
sub-interpreter. This thread state is made in the current thread state. |
| 878 |
Note that no actual thread is created; see the discussion of thread states |
| 879 |
below. If creation of the new interpreter is unsuccessful, NULL is |
| 880 |
returned; no exception is set since the exception state is stored in the |
| 881 |
current thread state and there may not be a current thread state. (Like all |
| 882 |
other Python/C API functions, the global interpreter lock must be held before |
| 883 |
calling this function and is still held when it returns; however, unlike most |
| 884 |
other Python/C API functions, there needn't be a current thread state on |
| 885 |
entry.) |
| 886 |
|
| 887 |
Extension modules are shared between (sub-)interpreters as follows: the first |
| 888 |
time a particular extension is imported, it is initialized normally, and a |
| 889 |
(shallow) copy of its module's dictionary is squirreled away. When the same |
| 890 |
extension is imported by another (sub-)interpreter, a new module is initialized |
| 891 |
and filled with the contents of this copy; the extension's init function is |
| 892 |
not called. Note that this is different from what happens when an extension is |
| 893 |
imported after the interpreter has been completely re-initialized by calling |
| 894 |
Py_Finalize() and Py_Initialize(); in that case, the extension's |
| 895 |
initmodule function is called again.""" |
| 896 |
raise NotImplementedError |
| 897 |
|
| 898 |
@cpython_api([PyThreadState], lltype.Void) |
| 899 |
def Py_EndInterpreter(space, tstate): |
| 900 |
"""Destroy the (sub-)interpreter represented by the given thread state. The |
| 901 |
given thread state must be the current thread state. See the discussion of |
| 902 |
thread states below. When the call returns, the current thread state is |
| 903 |
NULL. All thread states associated with this interpreter are destroyed. |
| 904 |
(The global interpreter lock must be held before calling this function and is |
| 905 |
still held when it returns.) Py_Finalize() will destroy all sub-interpreters |
| 906 |
that haven't been explicitly destroyed at that point.""" |
| 907 |
raise NotImplementedError |
| 908 |
|
| 909 |
@cpython_api([Py_tracefunc, PyObject], lltype.Void) |
| 910 |
def PyEval_SetProfile(space, func, obj): |
| 911 |
"""Set the profiler function to func. The obj parameter is passed to the |
| 912 |
function as its first parameter, and may be any Python object, or NULL. If |
| 913 |
the profile function needs to maintain state, using a different value for obj |
| 914 |
for each thread provides a convenient and thread-safe place to store it. The |
| 915 |
profile function is called for all monitored events except the line-number |
| 916 |
events.""" |
| 917 |
raise NotImplementedError |
| 918 |
|
| 919 |
@cpython_api([Py_tracefunc, PyObject], lltype.Void) |
| 920 |
def PyEval_SetTrace(space, func, obj): |
| 921 |
"""Set the tracing function to func. This is similar to |
| 922 |
PyEval_SetProfile(), except the tracing function does receive line-number |
| 923 |
events.""" |
| 924 |
raise NotImplementedError |
| 925 |
|
| 926 |
@cpython_api([PyObject], PyObject) |
| 927 |
def PyEval_GetCallStats(space, self): |
| 928 |
"""Return a tuple of function call counts. There are constants defined for the |
| 929 |
positions within the tuple: |
| 930 |
|
| 931 |
Name |
| 932 |
|
| 933 |
Value |
| 934 |
|
| 935 |
PCALL_ALL |
| 936 |
|
| 937 |
0 |
| 938 |
|
| 939 |
PCALL_FUNCTION |
| 940 |
|
| 941 |
1 |
| 942 |
|
| 943 |
PCALL_FAST_FUNCTION |
| 944 |
|
| 945 |
2 |
| 946 |
|
| 947 |
PCALL_FASTER_FUNCTION |
| 948 |
|
| 949 |
3 |
| 950 |
|
| 951 |
PCALL_METHOD |
| 952 |
|
| 953 |
4 |
| 954 |
|
| 955 |
PCALL_BOUND_METHOD |
| 956 |
|
| 957 |
5 |
| 958 |
|
| 959 |
PCALL_CFUNCTION |
| 960 |
|
| 961 |
6 |
| 962 |
|
| 963 |
PCALL_TYPE |
| 964 |
|
| 965 |
7 |
| 966 |
|
| 967 |
PCALL_GENERATOR |
| 968 |
|
| 969 |
8 |
| 970 |
|
| 971 |
PCALL_OTHER |
| 972 |
|
| 973 |
9 |
| 974 |
|
| 975 |
PCALL_POP |
| 976 |
|
| 977 |
10 |
| 978 |
|
| 979 |
PCALL_FAST_FUNCTION means no argument tuple needs to be created. |
| 980 |
PCALL_FASTER_FUNCTION means that the fast-path frame setup code is used. |
| 981 |
|
| 982 |
If there is a method call where the call can be optimized by changing |
| 983 |
the argument tuple and calling the function directly, it gets recorded |
| 984 |
twice. |
| 985 |
|
| 986 |
This function is only present if Python is compiled with CALL_PROFILE |
| 987 |
defined.""" |
| 988 |
raise NotImplementedError |
| 989 |
|
| 990 |
@cpython_api([PyInterpreterState], PyThreadState) |
| 991 |
def PyInterpreterState_ThreadHead(space, interp): |
| 992 |
"""Return the a pointer to the first PyThreadState object in the list of |
| 993 |
threads associated with the interpreter interp. |
| 994 |
""" |
| 995 |
raise NotImplementedError |
| 996 |
|
| 997 |
@cpython_api([PyThreadState], PyThreadState) |
| 998 |
def PyThreadState_Next(space, tstate): |
| 999 |
"""Return the next thread state object after tstate from the list of all such |
| 1000 |
objects belonging to the same PyInterpreterState object. |
| 1001 |
""" |
| 1002 |
raise NotImplementedError |
| 1003 |
|
| 1004 |
@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL) |
| 1005 |
def PySeqIter_Check(space, op): |
| 1006 |
"""Return true if the type of op is PySeqIter_Type. |
| 1007 |
""" |
| 1008 |
raise NotImplementedError |
| 1009 |
|
| 1010 |
@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL) |
| 1011 |
def PyCallIter_Check(space, op): |
| 1012 |
"""Return true if the type of op is PyCallIter_Type. |
| 1013 |
""" |
| 1014 |
raise NotImplementedError |
| 1015 |
|
| 1016 |
@cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1) |
| 1017 |
def PyMapping_DelItemString(space, o, key): |
| 1018 |
"""Remove the mapping for object key from the object o. Return -1 on |
| 1019 |
failure. This is equivalent to the Python statement del o[key].""" |
| 1020 |
raise NotImplementedError |
| 1021 |
|
| 1022 |
@cpython_api([PyObject, PyObject], rffi.INT_real, error=-1) |
| 1023 |
def PyMapping_DelItem(space, o, key): |
| 1024 |
"""Remove the mapping for object key from the object o. Return -1 on |
| 1025 |
failure. This is equivalent to the Python statement del o[key].""" |
| 1026 |
raise NotImplementedError |
| 1027 |
|
| 1028 |
@cpython_api([lltype.Signed, FILE, rffi.INT_real], lltype.Void) |
| 1029 |
def PyMarshal_WriteLongToFile(space, value, file, version): |
| 1030 |
"""Marshal a long integer, value, to file. This will only write |
| 1031 |
the least-significant 32 bits of value; regardless of the size of the |
| 1032 |
native long type. |
| 1033 |
|
| 1034 |
version indicates the file format.""" |
| 1035 |
raise NotImplementedError |
| 1036 |
|
| 1037 |
@cpython_api([PyObject, FILE, rffi.INT_real], lltype.Void) |
| 1038 |
def PyMarshal_WriteObjectToFile(space, value, file, version): |
| 1039 |
"""Marshal a Python object, value, to file. |
| 1040 |
|
| 1041 |
version indicates the file format.""" |
| 1042 |
raise NotImplementedError |
| 1043 |
|
| 1044 |
@cpython_api([FILE], lltype.Signed, error=-1) |
| 1045 |
def PyMarshal_ReadLongFromFile(space, file): |
| 1046 |
"""Return a C long from the data stream in a FILE* opened |
| 1047 |
for reading. Only a 32-bit value can be read in using this function, |
| 1048 |
regardless of the native size of long.""" |
| 1049 |
raise NotImplementedError |
| 1050 |
|
| 1051 |
@cpython_api([FILE], rffi.INT_real, error=-1) |
| 1052 |
def PyMarshal_ReadShortFromFile(space, file): |
| 1053 |
"""Return a C short from the data stream in a FILE* opened |
| 1054 |
for reading. Only a 16-bit value can be read in using this function, |
| 1055 |
regardless of the native size of short.""" |
| 1056 |
raise NotImplementedError |
| 1057 |
|
| 1058 |
@cpython_api([FILE], PyObject) |
| 1059 |
def PyMarshal_ReadObjectFromFile(space, file): |
| 1060 |
"""Return a Python object from the data stream in a FILE* opened for |
| 1061 |
reading. On error, sets the appropriate exception (EOFError or |
| 1062 |
TypeError) and returns NULL.""" |
| 1063 |
raise NotImplementedError |
| 1064 |
|
| 1065 |
@cpython_api([FILE], PyObject) |
| 1066 |
def PyMarshal_ReadLastObjectFromFile(space, file): |
| 1067 |
"""Return a Python object from the data stream in a FILE* opened for |
| 1068 |
reading. Unlike PyMarshal_ReadObjectFromFile(), this function |
| 1069 |
assumes that no further objects will be read from the file, allowing it to |
| 1070 |
aggressively load file data into memory so that the de-serialization can |
| 1071 |
operate from data in memory rather than reading a byte at a time from the |
| 1072 |
file. Only use these variant if you are certain that you won't be reading |
| 1073 |
anything else from the file. On error, sets the appropriate exception |
| 1074 |
(EOFError or TypeError) and returns NULL.""" |
| 1075 |
raise NotImplementedError |
| 1076 |
|
| 1077 |
@cpython_api([], rffi.INT_real, error=-1) |
| 1078 |
def PyMethod_ClearFreeList(space): |
| 1079 |
"""Clear the free list. Return the total number of freed items. |
| 1080 |
""" |
| 1081 |
raise NotImplementedError |
| 1082 |
|
| 1083 |
@cpython_api([PyObject], rffi.CCHARP) |
| 1084 |
def PyModule_GetFilename(space, module): |
| 1085 |
"""Similar to PyModule_GetFilenameObject() but return the filename |
| 1086 |
encoded to 'utf-8'. |
| 1087 |
|
| 1088 |
PyModule_GetFilename() raises UnicodeEncodeError on |
| 1089 |
unencodable filenames, use PyModule_GetFilenameObject() instead.""" |
| 1090 |
raise NotImplementedError |
| 1091 |
|
| 1092 |
@cpython_api([PyFrameObject], rffi.INT_real, error=-1) |
| 1093 |
def PyFrame_GetLineNumber(space, frame): |
| 1094 |
"""Return the line number that frame is currently executing.""" |
| 1095 |
raise NotImplementedError |
| 1096 |
|
| 1097 |
@cpython_api([PyObject, PyObject], Py_ssize_t, error=-1) |
| 1098 |
def PySequence_Count(space, o, value): |
| 1099 |
"""Return the number of occurrences of value in o, that is, return the number |
| 1100 |
of keys for which o[key] == value. On failure, return -1. This is |
| 1101 |
equivalent to the Python expression o.count(value).""" |
| 1102 |
raise NotImplementedError |
| 1103 |
|
| 1104 |
@cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1) |
| 1105 |
def Py_FdIsInteractive(space, fp, filename): |
| 1106 |
"""Return true (nonzero) if the standard I/O file fp with name filename is |
| 1107 |
deemed interactive. This is the case for files for which isatty(fileno(fp)) |
| 1108 |
is true. If the global flag Py_InteractiveFlag is true, this function |
| 1109 |
also returns true if the filename pointer is NULL or if the name is equal to |
| 1110 |
one of the strings '<stdin>' or '???'.""" |
| 1111 |
raise NotImplementedError |
| 1112 |
|
| 1113 |
@cpython_api([], rffi.INT_real, error=CANNOT_FAIL) |
| 1114 |
def PyOS_CheckStack(space): |
| 1115 |
"""Return true when the interpreter runs out of stack space. This is a reliable |
| 1116 |
check, but is only available when USE_STACKCHECK is defined (currently |
| 1117 |
on Windows using the Microsoft Visual C++ compiler). USE_STACKCHECK |
| 1118 |
will be defined automatically; you should never change the definition in your |
| 1119 |
own code.""" |
| 1120 |
raise NotImplementedError |
| 1121 |
|
| 1122 |
@cpython_api([rffi.CCHARP, FILE], FILE) |
| 1123 |
def PySys_GetFile(space, name, def_): |
| 1124 |
"""Return the FILE* associated with the object name in the |
| 1125 |
sys module, or def if name is not in the module or is not associated |
| 1126 |
with a FILE*.""" |
| 1127 |
raise NotImplementedError |
| 1128 |
|
| 1129 |
@cpython_api([], lltype.Void) |
| 1130 |
def PySys_ResetWarnOptions(space): |
| 1131 |
"""Reset sys.warnoptions to an empty list.""" |
| 1132 |
raise NotImplementedError |
| 1133 |
|
| 1134 |
@cpython_api([rffi.CWCHARP], lltype.Void) |
| 1135 |
def PySys_AddWarnOption(space, s): |
| 1136 |
"""Append s to sys.warnoptions.""" |
| 1137 |
raise NotImplementedError |
| 1138 |
|
| 1139 |
@cpython_api([PyObject], lltype.Void) |
| 1140 |
def PySys_AddWarnOptionUnicode(space, unicode): |
| 1141 |
"""Append unicode to sys.warnoptions.""" |
| 1142 |
raise NotImplementedError |
| 1143 |
|
| 1144 |
|
| 1145 |
@cpython_api([rffi.CWCHARP], lltype.Void) |
| 1146 |
def PySys_SetPath(space, path): |
| 1147 |
"""Set sys.path to a list object of paths found in path which should |
| 1148 |
be a list of paths separated with the platform's search path delimiter |
| 1149 |
(: on Unix, ; on Windows).""" |
| 1150 |
raise NotImplementedError |
| 1151 |
|
| 1152 |
@cpython_api([rffi.CCHARP, ], lltype.Void) |
| 1153 |
def PySys_FormatStdout(space, format, ): |
| 1154 |
"""Function similar to PySys_WriteStdout() but format the message using |
| 1155 |
PyUnicode_FromFormatV() and don't truncate the message to an |
| 1156 |
arbitrary length. |
| 1157 |
""" |
| 1158 |
raise NotImplementedError |
| 1159 |
|
| 1160 |
@cpython_api([rffi.CCHARP, ], lltype.Void) |
| 1161 |
def PySys_FormatStderr(space, format, ): |
| 1162 |
"""As PySys_FormatStdout(), but write to sys.stderr or stderr |
| 1163 |
instead. |
| 1164 |
""" |
| 1165 |
raise NotImplementedError |
| 1166 |
|
| 1167 |
@cpython_api([rffi.CWCHARP], lltype.Void) |
| 1168 |
def PySys_AddXOption(space, s): |
| 1169 |
"""Parse s as a set of -X options and add them to the current |
| 1170 |
options mapping as returned by PySys_GetXOptions(). |
| 1171 |
""" |
| 1172 |
raise NotImplementedError |
| 1173 |
|
| 1174 |
@cpython_api([], PyObject) |
| 1175 |
def PySys_GetXOptions(space, ): |
| 1176 |
"""Return the current dictionary of -X options, similarly to |
| 1177 |
sys._xoptions. On error, NULL is returned and an exception is |
| 1178 |
set. |
| 1179 |
""" |
| 1180 |
raise NotImplementedError |
| 1181 |
borrow_from() |
| 1182 |
|
| 1183 |
@cpython_api([rffi.INT_real], lltype.Void) |
| 1184 |
def Py_Exit(space, status): |
| 1185 |
""" |
| 1186 |
Exit the current process. This calls Py_Finalize() and then calls the |
| 1187 |
standard C library function exit(status).""" |
| 1188 |
raise NotImplementedError |
| 1189 |
|
| 1190 |
@cpython_api([], rffi.INT_real, error=-1) |
| 1191 |
def PyTuple_ClearFreeList(space, ): |
| 1192 |
"""Clear the free list. Return the total number of freed items.""" |
| 1193 |
raise NotImplementedError |
| 1194 |
|
| 1195 |
|
| 1196 |
@cpython_api([], rffi.UINT, error=CANNOT_FAIL) |
| 1197 |
def PyType_ClearCache(space, ): |
| 1198 |
"""Clear the internal lookup cache. Return the current version tag.""" |
| 1199 |
raise NotImplementedError |
| 1200 |
|
| 1201 |
|
| 1202 |
@cpython_api([], rffi.INT_real, error=-1) |
| 1203 |
def PyUnicode_ClearFreeList(space, ): |
| 1204 |
"""Clear the free list. Return the total number of freed items.""" |
| 1205 |
raise NotImplementedError |
| 1206 |
|
| 1207 |
|
| 1208 |
@cpython_api([PyObject], rffi.CArrayPtr(Py_UNICODE)) |
| 1209 |
def PyUnicode_AsUnicodeCopy(space, unicode): |
| 1210 |
"""Create a copy of a Unicode string ending with a nul character. Return NULL |
| 1211 |
and raise a MemoryError exception on memory allocation failure, |
| 1212 |
otherwise return a new allocated buffer (use PyMem_Free() to free |
| 1213 |
the buffer). Note that the resulting Py_UNICODE* string may contain |
| 1214 |
embedded null characters, which would cause the string to be truncated when |
| 1215 |
used in most C functions. |
| 1216 |
""" |
| 1217 |
raise NotImplementedError |
| 1218 |
|
| 1219 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, rffi.CCHARP, rffi.CCHARP], PyObject) |
| 1220 |
def PyUnicode_Encode(space, s, size, encoding, errors): |
| 1221 |
"""Encode the Py_UNICODE buffer s of the given size and return a Python |
| 1222 |
bytes object. encoding and errors have the same meaning as the |
| 1223 |
parameters of the same name in the Unicode encode() method. The codec |
| 1224 |
to be used is looked up using the Python codec registry. Return NULL if an |
| 1225 |
exception was raised by the codec.""" |
| 1226 |
raise NotImplementedError |
| 1227 |
|
| 1228 |
@cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, Py_ssize_t], PyObject) |
| 1229 |
def PyUnicode_DecodeUTF8Stateful(space, s, size, errors, consumed): |
| 1230 |
"""If consumed is NULL, behave like PyUnicode_DecodeUTF8(). If |
| 1231 |
consumed is not NULL, trailing incomplete UTF-8 byte sequences will not be |
| 1232 |
treated as an error. Those bytes will not be decoded and the number of bytes |
| 1233 |
that have been decoded will be stored in consumed.""" |
| 1234 |
raise NotImplementedError |
| 1235 |
|
| 1236 |
@cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, rffi.INTP, Py_ssize_t], PyObject) |
| 1237 |
def PyUnicode_DecodeUTF32Stateful(space, s, size, errors, byteorder, consumed): |
| 1238 |
"""If consumed is NULL, behave like PyUnicode_DecodeUTF32(). If |
| 1239 |
consumed is not NULL, PyUnicode_DecodeUTF32Stateful() will not treat |
| 1240 |
trailing incomplete UTF-32 byte sequences (such as a number of bytes not divisible |
| 1241 |
by four) as an error. Those bytes will not be decoded and the number of bytes |
| 1242 |
that have been decoded will be stored in consumed.""" |
| 1243 |
raise NotImplementedError |
| 1244 |
|
| 1245 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, rffi.CCHARP, rffi.INT_real], PyObject) |
| 1246 |
def PyUnicode_EncodeUTF32(space, s, size, errors, byteorder): |
| 1247 |
"""Return a Python bytes object holding the UTF-32 encoded value of the Unicode |
| 1248 |
data in s. Output is written according to the following byte order: |
| 1249 |
|
| 1250 |
byteorder == -1: little endian |
| 1251 |
byteorder == 0: native byte order (writes a BOM mark) |
| 1252 |
byteorder == 1: big endian |
| 1253 |
|
| 1254 |
If byteorder is 0, the output string will always start with the Unicode BOM |
| 1255 |
mark (U+FEFF). In the other two modes, no BOM mark is prepended. |
| 1256 |
|
| 1257 |
If Py_UNICODE_WIDE is not defined, surrogate pairs will be output |
| 1258 |
as a single codepoint. |
| 1259 |
|
| 1260 |
Return NULL if an exception was raised by the codec. |
| 1261 |
""" |
| 1262 |
raise NotImplementedError |
| 1263 |
|
| 1264 |
@cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, rffi.INTP, Py_ssize_t], PyObject) |
| 1265 |
def PyUnicode_DecodeUTF16Stateful(space, s, size, errors, byteorder, consumed): |
| 1266 |
"""If consumed is NULL, behave like PyUnicode_DecodeUTF16(). If |
| 1267 |
consumed is not NULL, PyUnicode_DecodeUTF16Stateful() will not treat |
| 1268 |
trailing incomplete UTF-16 byte sequences (such as an odd number of bytes or a |
| 1269 |
split surrogate pair) as an error. Those bytes will not be decoded and the |
| 1270 |
number of bytes that have been decoded will be stored in consumed.""" |
| 1271 |
raise NotImplementedError |
| 1272 |
|
| 1273 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, rffi.CCHARP, rffi.INT_real], PyObject) |
| 1274 |
def PyUnicode_EncodeUTF16(space, s, size, errors, byteorder): |
| 1275 |
"""Return a Python bytes object holding the UTF-16 encoded value of the Unicode |
| 1276 |
data in s. Output is written according to the following byte order: |
| 1277 |
|
| 1278 |
byteorder == -1: little endian |
| 1279 |
byteorder == 0: native byte order (writes a BOM mark) |
| 1280 |
byteorder == 1: big endian |
| 1281 |
|
| 1282 |
If byteorder is 0, the output string will always start with the Unicode BOM |
| 1283 |
mark (U+FEFF). In the other two modes, no BOM mark is prepended. |
| 1284 |
|
| 1285 |
If Py_UNICODE_WIDE is defined, a single Py_UNICODE value may get |
| 1286 |
represented as a surrogate pair. If it is not defined, each Py_UNICODE |
| 1287 |
values is interpreted as an UCS-2 character. |
| 1288 |
|
| 1289 |
Return NULL if an exception was raised by the codec.""" |
| 1290 |
raise NotImplementedError |
| 1291 |
|
| 1292 |
@cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP], PyObject) |
| 1293 |
def PyUnicode_DecodeUTF7(space, s, size, errors): |
| 1294 |
"""Create a Unicode object by decoding size bytes of the UTF-7 encoded string |
| 1295 |
s. Return NULL if an exception was raised by the codec.""" |
| 1296 |
raise NotImplementedError |
| 1297 |
|
| 1298 |
@cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, Py_ssize_t], PyObject) |
| 1299 |
def PyUnicode_DecodeUTF7Stateful(space, s, size, errors, consumed): |
| 1300 |
"""If consumed is NULL, behave like PyUnicode_DecodeUTF7(). If |
| 1301 |
consumed is not NULL, trailing incomplete UTF-7 base-64 sections will not |
| 1302 |
be treated as an error. Those bytes will not be decoded and the number of |
| 1303 |
bytes that have been decoded will be stored in consumed.""" |
| 1304 |
raise NotImplementedError |
| 1305 |
|
| 1306 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, rffi.INT_real, rffi.INT_real, rffi.CCHARP], PyObject) |
| 1307 |
def PyUnicode_EncodeUTF7(space, s, size, base64SetO, base64WhiteSpace, errors): |
| 1308 |
"""Encode the Py_UNICODE buffer of the given size using UTF-7 and |
| 1309 |
return a Python bytes object. Return NULL if an exception was raised by |
| 1310 |
the codec. |
| 1311 |
|
| 1312 |
If base64SetO is nonzero, "Set O" (punctuation that has no otherwise |
| 1313 |
special meaning) will be encoded in base-64. If base64WhiteSpace is |
| 1314 |
nonzero, whitespace will be encoded in base-64. Both are set to zero for the |
| 1315 |
Python "utf-7" codec.""" |
| 1316 |
raise NotImplementedError |
| 1317 |
|
| 1318 |
@cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP], PyObject) |
| 1319 |
def PyUnicode_DecodeUnicodeEscape(space, s, size, errors): |
| 1320 |
"""Create a Unicode object by decoding size bytes of the Unicode-Escape encoded |
| 1321 |
string s. Return NULL if an exception was raised by the codec.""" |
| 1322 |
raise NotImplementedError |
| 1323 |
|
| 1324 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t], PyObject) |
| 1325 |
def PyUnicode_EncodeUnicodeEscape(space, s, size): |
| 1326 |
"""Encode the Py_UNICODE buffer of the given size using Unicode-Escape and |
| 1327 |
return a Python string object. Return NULL if an exception was raised by the |
| 1328 |
codec.""" |
| 1329 |
raise NotImplementedError |
| 1330 |
|
| 1331 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, rffi.CCHARP], PyObject) |
| 1332 |
def PyUnicode_EncodeRawUnicodeEscape(space, s, size, errors): |
| 1333 |
"""Encode the Py_UNICODE buffer of the given size using Raw-Unicode-Escape |
| 1334 |
and return a Python string object. Return NULL if an exception was raised by |
| 1335 |
the codec.""" |
| 1336 |
raise NotImplementedError |
| 1337 |
|
| 1338 |
@cpython_api([rffi.CCHARP, Py_ssize_t, PyObject, rffi.CCHARP], PyObject) |
| 1339 |
def PyUnicode_DecodeCharmap(space, s, size, mapping, errors): |
| 1340 |
"""Create a Unicode object by decoding size bytes of the encoded string s using |
| 1341 |
the given mapping object. Return NULL if an exception was raised by the |
| 1342 |
codec. If mapping is NULL latin-1 decoding will be done. Else it can be a |
| 1343 |
dictionary mapping byte or a unicode string, which is treated as a lookup table. |
| 1344 |
Byte values greater that the length of the string and U+FFFE "characters" are |
| 1345 |
treated as "undefined mapping".""" |
| 1346 |
raise NotImplementedError |
| 1347 |
|
| 1348 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, PyObject, rffi.CCHARP], PyObject) |
| 1349 |
def PyUnicode_EncodeCharmap(space, s, size, mapping, errors): |
| 1350 |
"""Encode the Py_UNICODE buffer of the given size using the given |
| 1351 |
mapping object and return a Python string object. Return NULL if an |
| 1352 |
exception was raised by the codec.""" |
| 1353 |
raise NotImplementedError |
| 1354 |
|
| 1355 |
@cpython_api([PyObject, PyObject], PyObject) |
| 1356 |
def PyUnicode_AsCharmapString(space, unicode, mapping): |
| 1357 |
"""Encode a Unicode object using the given mapping object and return the result |
| 1358 |
as Python string object. Error handling is "strict". Return NULL if an |
| 1359 |
exception was raised by the codec.""" |
| 1360 |
raise NotImplementedError |
| 1361 |
|
| 1362 |
@cpython_api([rffi.CArrayPtr(Py_UNICODE), Py_ssize_t, PyObject, rffi.CCHARP], PyObject) |
| 1363 |
def PyUnicode_TranslateCharmap(space, s, size, table, errors): |
| 1364 |
"""Translate a Py_UNICODE buffer of the given size by applying a |
| 1365 |
character mapping table to it and return the resulting Unicode object. Return |
| 1366 |
NULL when an exception was raised by the codec. |
| 1367 |
|
| 1368 |
The mapping table must map Unicode ordinal integers to Unicode ordinal |
| 1369 |
integers or None (causing deletion of the character). |
| 1370 |
|
| 1371 |
Mapping tables need only provide the __getitem__() interface; dictionaries |
| 1372 |
and sequences work well. Unmapped character ordinals (ones which cause a |
| 1373 |
LookupError) are left untouched and are copied as-is.""" |
| 1374 |
raise NotImplementedError |
| 1375 |
|
| 1376 |
@cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP], PyObject) |
| 1377 |
def PyUnicode_DecodeMBCS(space, s, size, errors): |
| 1378 |
"""Create a Unicode object by decoding size bytes of the MBCS encoded string s. |
| 1379 |
Return NULL if an exception was raised by the codec.""" |
| 1380 |
raise NotImplementedError |
| 1381 |
|
| 1382 |
@cpython_api([rffi.CCHARP, rffi.INT_real, rffi.CCHARP, rffi.INTP], PyObject) |
| 1383 |
def PyUnicode_DecodeMBCSStateful(space, s, size, errors, consumed): |
| 1384 |
"""If consumed is NULL, behave like PyUnicode_DecodeMBCS(). If |
| 1385 |
consumed is not NULL, PyUnicode_DecodeMBCSStateful() will not decode |
| 1386 |
trailing lead byte and the number of bytes that have been decoded will be stored |
| 1387 |
in consumed.""" |
| 1388 |
raise NotImplementedError |
| 1389 |
|
| 1390 |
@cpython_api([PyObject], PyObject) |
| 1391 |
def PyUnicode_AsMBCSString(space, unicode): |
| 1392 |
"""Encode a Unicode object using MBCS and return the result as Python bytes |
| 1393 |
object. Error handling is "strict". Return NULL if an exception was |
| 1394 |
raised by the codec.""" |
| 1395 |
raise NotImplementedError |
| 1396 |
|
| 1397 |
|
| 1398 |
@cpython_api([PyObject, PyObject, rffi.CCHARP], PyObject) |
| 1399 |
def PyUnicode_Translate(space, str, table, errors): |
| 1400 |
"""Translate a string by applying a character mapping table to it and return the |
| 1401 |
resulting Unicode object. |
| 1402 |
|
| 1403 |
The mapping table must map Unicode ordinal integers to Unicode ordinal integers |
| 1404 |
or None (causing deletion of the character). |
| 1405 |
|
| 1406 |
Mapping tables need only provide the __getitem__() interface; dictionaries |
| 1407 |
and sequences work well. Unmapped character ordinals (ones which cause a |
| 1408 |
LookupError) are left untouched and are copied as-is. |
| 1409 |
|
| 1410 |
errors has the usual meaning for codecs. It may be NULL which indicates to |
| 1411 |
use the default error handling.""" |
| 1412 |
raise NotImplementedError |
| 1413 |
|
| 1414 |
@cpython_api([PyObject, PyObject, rffi.INT_real], PyObject) |
| 1415 |
def PyUnicode_RichCompare(space, left, right, op): |
| 1416 |
"""Rich compare two unicode strings and return one of the following: |
| 1417 |
|
| 1418 |
NULL in case an exception was raised |
| 1419 |
|
| 1420 |
Py_True or Py_False for successful comparisons |
| 1421 |
|
| 1422 |
Py_NotImplemented in case the type combination is unknown |
| 1423 |
|
| 1424 |
Note that Py_EQ and Py_NE comparisons can cause a |
| 1425 |
UnicodeWarning in case the conversion of the arguments to Unicode fails |
| 1426 |
with a UnicodeDecodeError. |
| 1427 |
|
| 1428 |
Possible values for op are Py_GT, Py_GE, Py_EQ, |
| 1429 |
Py_NE, Py_LT, and Py_LE.""" |
| 1430 |
raise NotImplementedError |
| 1431 |
|
| 1432 |
|
| 1433 |
@cpython_api([rffi.INT_real, CWCHARPP], rffi.INT_real, error=1) |
| 1434 |
def Py_Main(space, argc, argv): |
| 1435 |
"""The main program for the standard interpreter. This is made available for |
| 1436 |
programs which embed Python. The argc and argv parameters should be |
| 1437 |
prepared exactly as those which are passed to a C program's main() |
| 1438 |
function (converted to wchar_t according to the user's locale). It is |
| 1439 |
important to note that the argument list may be modified (but the contents of |
| 1440 |
the strings pointed to by the argument list are not). The return value will |
| 1441 |
be 0 if the interpreter exits normally (i.e., without an exception), |
| 1442 |
1 if the interpreter exits due to an exception, or 2 if the parameter |
| 1443 |
list does not represent a valid Python command line. |
| 1444 |
|
| 1445 |
Note that if an otherwise unhandled SystemExit is raised, this |
| 1446 |
function will not return 1, but exit the process, as long as |
| 1447 |
Py_InspectFlag is not set.""" |
| 1448 |
raise NotImplementedError |
| 1449 |
|
| 1450 |
@cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1) |
| 1451 |
def PyRun_AnyFile(space, fp, filename): |
| 1452 |
"""This is a simplified interface to PyRun_AnyFileExFlags() below, leaving |
| 1453 |
closeit set to 0 and flags set to NULL.""" |
| 1454 |
raise NotImplementedError |
| 1455 |
|
| 1456 |
@cpython_api([FILE, rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1) |
| 1457 |
def PyRun_AnyFileFlags(space, fp, filename, flags): |
| 1458 |
"""This is a simplified interface to PyRun_AnyFileExFlags() below, leaving |
| 1459 |
the closeit argument set to 0.""" |
| 1460 |
raise NotImplementedError |
| 1461 |
|
| 1462 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real], rffi.INT_real, error=-1) |
| 1463 |
def PyRun_AnyFileEx(space, fp, filename, closeit): |
| 1464 |
"""This is a simplified interface to PyRun_AnyFileExFlags() below, leaving |
| 1465 |
the flags argument set to NULL.""" |
| 1466 |
raise NotImplementedError |
| 1467 |
|
| 1468 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyCompilerFlags], rffi.INT_real, error=-1) |
| 1469 |
def PyRun_AnyFileExFlags(space, fp, filename, closeit, flags): |
| 1470 |
"""If fp refers to a file associated with an interactive device (console or |
| 1471 |
terminal input or Unix pseudo-terminal), return the value of |
| 1472 |
PyRun_InteractiveLoop(), otherwise return the result of |
| 1473 |
PyRun_SimpleFile(). filename is decoded from the filesystem |
| 1474 |
encoding (sys.getfilesystemencoding()). If filename is NULL, this |
| 1475 |
function uses "???" as the filename.""" |
| 1476 |
raise NotImplementedError |
| 1477 |
|
| 1478 |
@cpython_api([rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1) |
| 1479 |
def PyRun_SimpleStringFlags(space, command, flags): |
| 1480 |
"""Executes the Python source code from command in the __main__ module |
| 1481 |
according to the flags argument. If __main__ does not already exist, it |
| 1482 |
is created. Returns 0 on success or -1 if an exception was raised. If |
| 1483 |
there was an error, there is no way to get the exception information. For the |
| 1484 |
meaning of flags, see below. |
| 1485 |
|
| 1486 |
Note that if an otherwise unhandled SystemExit is raised, this |
| 1487 |
function will not return -1, but exit the process, as long as |
| 1488 |
Py_InspectFlag is not set.""" |
| 1489 |
raise NotImplementedError |
| 1490 |
|
| 1491 |
@cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1) |
| 1492 |
def PyRun_SimpleFile(space, fp, filename): |
| 1493 |
"""This is a simplified interface to PyRun_SimpleFileExFlags() below, |
| 1494 |
leaving closeit set to 0 and flags set to NULL.""" |
| 1495 |
raise NotImplementedError |
| 1496 |
|
| 1497 |
@cpython_api([FILE, rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1) |
| 1498 |
def PyRun_SimpleFileFlags(space, fp, filename, flags): |
| 1499 |
"""This is a simplified interface to PyRun_SimpleFileExFlags() below, |
| 1500 |
leaving closeit set to 0.""" |
| 1501 |
raise NotImplementedError |
| 1502 |
|
| 1503 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real], rffi.INT_real, error=-1) |
| 1504 |
def PyRun_SimpleFileEx(space, fp, filename, closeit): |
| 1505 |
"""This is a simplified interface to PyRun_SimpleFileExFlags() below, |
| 1506 |
leaving flags set to NULL.""" |
| 1507 |
raise NotImplementedError |
| 1508 |
|
| 1509 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyCompilerFlags], rffi.INT_real, error=-1) |
| 1510 |
def PyRun_SimpleFileExFlags(space, fp, filename, closeit, flags): |
| 1511 |
"""Similar to PyRun_SimpleStringFlags(), but the Python source code is read |
| 1512 |
from fp instead of an in-memory string. filename should be the name of |
| 1513 |
the file, it is decoded from the filesystem encoding |
| 1514 |
(sys.getfilesystemencoding()). If closeit is true, the file is |
| 1515 |
closed before PyRun_SimpleFileExFlags returns.""" |
| 1516 |
raise NotImplementedError |
| 1517 |
|
| 1518 |
@cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1) |
| 1519 |
def PyRun_InteractiveOne(space, fp, filename): |
| 1520 |
"""This is a simplified interface to PyRun_InteractiveOneFlags() below, |
| 1521 |
leaving flags set to NULL.""" |
| 1522 |
raise NotImplementedError |
| 1523 |
|
| 1524 |
@cpython_api([FILE, rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1) |
| 1525 |
def PyRun_InteractiveOneFlags(space, fp, filename, flags): |
| 1526 |
"""Read and execute a single statement from a file associated with an |
| 1527 |
interactive device according to the flags argument. The user will be |
| 1528 |
prompted using sys.ps1 and sys.ps2. filename is decoded from the |
| 1529 |
filesystem encoding (sys.getfilesystemencoding()). |
| 1530 |
|
| 1531 |
Returns 0 when the input was |
| 1532 |
executed successfully, -1 if there was an exception, or an error code |
| 1533 |
from the errcode.h include file distributed as part of Python if |
| 1534 |
there was a parse error. (Note that errcode.h is not included by |
| 1535 |
Python.h, so must be included specifically if needed.)""" |
| 1536 |
raise NotImplementedError |
| 1537 |
|
| 1538 |
@cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1) |
| 1539 |
def PyRun_InteractiveLoop(space, fp, filename): |
| 1540 |
"""This is a simplified interface to PyRun_InteractiveLoopFlags() below, |
| 1541 |
leaving flags set to NULL.""" |
| 1542 |
raise NotImplementedError |
| 1543 |
|
| 1544 |
@cpython_api([FILE, rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1) |
| 1545 |
def PyRun_InteractiveLoopFlags(space, fp, filename, flags): |
| 1546 |
"""Read and execute statements from a file associated with an interactive device |
| 1547 |
until EOF is reached. The user will be prompted using sys.ps1 and |
| 1548 |
sys.ps2. filename is decoded from the filesystem encoding |
| 1549 |
(sys.getfilesystemencoding()). Returns 0 at EOF.""" |
| 1550 |
raise NotImplementedError |
| 1551 |
|
| 1552 |
@cpython_api([rffi.CCHARP, rffi.INT_real], struct_node) |
| 1553 |
def PyParser_SimpleParseString(space, str, start): |
| 1554 |
"""This is a simplified interface to |
| 1555 |
PyParser_SimpleParseStringFlagsFilename() below, leaving filename set |
| 1556 |
to NULL and flags set to 0.""" |
| 1557 |
raise NotImplementedError |
| 1558 |
|
| 1559 |
@cpython_api([rffi.CCHARP, rffi.INT_real, rffi.INT_real], struct_node) |
| 1560 |
def PyParser_SimpleParseStringFlags(space, str, start, flags): |
| 1561 |
"""This is a simplified interface to |
| 1562 |
PyParser_SimpleParseStringFlagsFilename() below, leaving filename set |
| 1563 |
to NULL.""" |
| 1564 |
raise NotImplementedError |
| 1565 |
|
| 1566 |
@cpython_api([rffi.CCHARP, rffi.CCHARP, rffi.INT_real, rffi.INT_real], struct_node) |
| 1567 |
def PyParser_SimpleParseStringFlagsFilename(space, str, filename, start, flags): |
| 1568 |
"""Parse Python source code from str using the start token start according to |
| 1569 |
the flags argument. The result can be used to create a code object which can |
| 1570 |
be evaluated efficiently. This is useful if a code fragment must be evaluated |
| 1571 |
many times. filename is decoded from the filesystem encoding |
| 1572 |
(sys.getfilesystemencoding()).""" |
| 1573 |
raise NotImplementedError |
| 1574 |
|
| 1575 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real], struct_node) |
| 1576 |
def PyParser_SimpleParseFile(space, fp, filename, start): |
| 1577 |
"""This is a simplified interface to PyParser_SimpleParseFileFlags() below, |
| 1578 |
leaving flags set to 0""" |
| 1579 |
raise NotImplementedError |
| 1580 |
|
| 1581 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real, rffi.INT_real], struct_node) |
| 1582 |
def PyParser_SimpleParseFileFlags(space, fp, filename, start, flags): |
| 1583 |
"""Similar to PyParser_SimpleParseStringFlagsFilename(), but the Python |
| 1584 |
source code is read from fp instead of an in-memory string.""" |
| 1585 |
raise NotImplementedError |
| 1586 |
|
| 1587 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyObject, PyObject, rffi.INT_real], PyObject) |
| 1588 |
def PyRun_FileEx(space, fp, filename, start, globals, locals, closeit): |
| 1589 |
"""This is a simplified interface to PyRun_FileExFlags() below, leaving |
| 1590 |
flags set to NULL.""" |
| 1591 |
raise NotImplementedError |
| 1592 |
|
| 1593 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyObject, PyObject, PyCompilerFlags], PyObject) |
| 1594 |
def PyRun_FileFlags(space, fp, filename, start, globals, locals, flags): |
| 1595 |
"""This is a simplified interface to PyRun_FileExFlags() below, leaving |
| 1596 |
closeit set to 0.""" |
| 1597 |
raise NotImplementedError |
| 1598 |
|
| 1599 |
@cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyObject, PyObject, rffi.INT_real, PyCompilerFlags], PyObject) |
| 1600 |
def PyRun_FileExFlags(space, fp, filename, start, globals, locals, closeit, flags): |
| 1601 |
"""Similar to PyRun_StringFlags(), but the Python source code is read from |
| 1602 |
fp instead of an in-memory string. filename should be the name of the file, |
| 1603 |
it is decoded from the filesystem encoding (sys.getfilesystemencoding()). |
| 1604 |
If closeit is true, the file is closed before PyRun_FileExFlags() |
| 1605 |
returns.""" |
| 1606 |
raise NotImplementedError |
| 1607 |
|
| 1608 |
@cpython_api([rffi.CCHARP, rffi.CCHARP, rffi.INT_real, PyCompilerFlags, rffi.INT_real], PyObject) |
| 1609 |
def Py_CompileStringExFlags(space, str, filename, start, flags, optimize): |
| 1610 |
"""Parse and compile the Python source code in str, returning the resulting code |
| 1611 |
object. The start token is given by start; this can be used to constrain the |
| 1612 |
code which can be compiled and should be Py_eval_input, |
| 1613 |
Py_file_input, or Py_single_input. The filename specified by |
| 1614 |
filename is used to construct the code object and may appear in tracebacks or |
| 1615 |
SyntaxError exception messages, it is decoded from the filesystem |
| 1616 |
encoding (sys.getfilesystemencoding()). This returns NULL if the |
| 1617 |
code cannot be parsed or compiled. |
| 1618 |
|
| 1619 |
The integer optimize specifies the optimization level of the compiler; a |
| 1620 |
value of -1 selects the optimization level of the interpreter as given by |
| 1621 |
-O options. Explicit levels are 0 (no optimization; |
| 1622 |
__debug__ is true), 1 (asserts are removed, __debug__ is false) |
| 1623 |
or 2 (docstrings are removed too). |
| 1624 |
""" |
| 1625 |
raise NotImplementedError |
| 1626 |
|
| 1627 |
|
| 1628 |
@cpython_api([PyObject, PyObject, PyObject, PyObjectP, rffi.INT_real, PyObjectP, rffi.INT_real, PyObjectP, rffi.INT_real, PyObject], PyObject) |
| 1629 |
def PyEval_EvalCodeEx(space, co, globals, locals, args, argcount, kws, kwcount, defs, defcount, closure): |
| 1630 |
"""Evaluate a precompiled code object, given a particular environment for its |
| 1631 |
evaluation. This environment consists of dictionaries of global and local |
| 1632 |
variables, arrays of arguments, keywords and defaults, and a closure tuple of |
| 1633 |
cells.""" |
| 1634 |
raise NotImplementedError |
| 1635 |
|
| 1636 |
@cpython_api([PyFrameObject], PyObject) |
| 1637 |
def PyEval_EvalFrame(space, f): |
| 1638 |
"""Evaluate an execution frame. This is a simplified interface to |
| 1639 |
PyEval_EvalFrameEx, for backward compatibility.""" |
| 1640 |
raise NotImplementedError |
| 1641 |
|
| 1642 |
@cpython_api([PyFrameObject, rffi.INT_real], PyObject) |
| 1643 |
def PyEval_EvalFrameEx(space, f, throwflag): |
| 1644 |
"""This is the main, unvarnished function of Python interpretation. It is |
| 1645 |
literally 2000 lines long. The code object associated with the execution |
| 1646 |
frame f is executed, interpreting bytecode and executing calls as needed. |
| 1647 |
The additional throwflag parameter can mostly be ignored - if true, then |
| 1648 |
it causes an exception to immediately be thrown; this is used for the |
| 1649 |
throw() methods of generator objects.""" |
| 1650 |
raise NotImplementedError |