PageRenderTime 73ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/pypy/module/cpyext/stubs.py

https://bitbucket.org/jonathanslenders/pypy
Python | 2420 lines | 2411 code | 5 blank | 4 comment | 1 complexity | 0bccf61c079b150c0d59a52623d707f8 MD5 | raw file
  1. from pypy.module.cpyext.api import (
  2. cpython_api, PyObject, PyObjectP, CANNOT_FAIL
  3. )
  4. from pypy.module.cpyext.complexobject import Py_complex_ptr as Py_complex
  5. from rpython.rtyper.lltypesystem import rffi, lltype
  6. # we don't really care
  7. PyTypeObjectPtr = rffi.VOIDP
  8. Py_ssize_t = rffi.SSIZE_T
  9. PyMethodDef = rffi.VOIDP
  10. PyGetSetDef = rffi.VOIDP
  11. PyMemberDef = rffi.VOIDP
  12. Py_buffer = rffi.VOIDP
  13. va_list = rffi.VOIDP
  14. PyDateTime_Date = rffi.VOIDP
  15. PyDateTime_DateTime = rffi.VOIDP
  16. PyDateTime_Time = rffi.VOIDP
  17. wrapperbase = rffi.VOIDP
  18. FILE = rffi.VOIDP
  19. PyFileObject = rffi.VOIDP
  20. PyCodeObject = rffi.VOIDP
  21. PyFrameObject = rffi.VOIDP
  22. PyFloatObject = rffi.VOIDP
  23. _inittab = rffi.VOIDP
  24. PyThreadState = rffi.VOIDP
  25. PyInterpreterState = rffi.VOIDP
  26. Py_UNICODE = lltype.UniChar
  27. PyCompilerFlags = rffi.VOIDP
  28. _node = rffi.VOIDP
  29. Py_tracefunc = rffi.VOIDP
  30. @cpython_api([PyObject], lltype.Void)
  31. def _PyObject_Del(space, op):
  32. raise NotImplementedError
  33. @cpython_api([rffi.CCHARP], Py_ssize_t, error=CANNOT_FAIL)
  34. def PyBuffer_SizeFromFormat(space, format):
  35. """Return the implied ~Py_buffer.itemsize from the struct-stype
  36. ~Py_buffer.format."""
  37. raise NotImplementedError
  38. @cpython_api([rffi.INT_real, Py_ssize_t, Py_ssize_t, Py_ssize_t, lltype.Char], lltype.Void)
  39. def PyBuffer_FillContiguousStrides(space, ndim, shape, strides, itemsize, fortran):
  40. """Fill the strides array with byte-strides of a contiguous (C-style if
  41. fortran is 'C' or Fortran-style if fortran is 'F' array of the
  42. given shape with the given number of bytes per element."""
  43. raise NotImplementedError
  44. @cpython_api([Py_buffer], PyObject)
  45. def PyMemoryView_FromBuffer(space, view):
  46. """Create a memoryview object wrapping the given buffer-info structure view.
  47. The memoryview object then owns the buffer, which means you shouldn't
  48. try to release it yourself: it will be released on deallocation of the
  49. memoryview object."""
  50. raise NotImplementedError
  51. @cpython_api([PyObject, rffi.INT_real, lltype.Char], PyObject)
  52. def PyMemoryView_GetContiguous(space, obj, buffertype, order):
  53. """Create a memoryview object to a contiguous chunk of memory (in either
  54. 'C' or 'F'ortran order) from an object that defines the buffer
  55. interface. If memory is contiguous, the memoryview object points to the
  56. original memory. Otherwise copy is made and the memoryview points to a
  57. new bytes object."""
  58. raise NotImplementedError
  59. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  60. def PyMemoryView_Check(space, obj):
  61. """Return true if the object obj is a memoryview object. It is not
  62. currently allowed to create subclasses of memoryview."""
  63. raise NotImplementedError
  64. @cpython_api([PyObject], Py_buffer)
  65. def PyMemoryView_GET_BUFFER(space, obj):
  66. """Return a pointer to the buffer-info structure wrapped by the given
  67. object. The object must be a memoryview instance; this macro doesn't
  68. check its type, you must do it yourself or you will risk crashes."""
  69. raise NotImplementedError
  70. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  71. def PyByteArray_Check(space, o):
  72. """Return true if the object o is a bytearray object or an instance of a
  73. subtype of the bytearray type."""
  74. raise NotImplementedError
  75. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  76. def PyByteArray_CheckExact(space, o):
  77. """Return true if the object o is a bytearray object, but not an instance of a
  78. subtype of the bytearray type."""
  79. raise NotImplementedError
  80. @cpython_api([PyObject], PyObject)
  81. def PyByteArray_FromObject(space, o):
  82. """Return a new bytearray object from any object, o, that implements the
  83. buffer protocol.
  84. XXX expand about the buffer protocol, at least somewhere"""
  85. raise NotImplementedError
  86. @cpython_api([rffi.CCHARP, Py_ssize_t], PyObject)
  87. def PyByteArray_FromStringAndSize(space, string, len):
  88. """Create a new bytearray object from string and its length, len. On
  89. failure, NULL is returned."""
  90. raise NotImplementedError
  91. @cpython_api([PyObject, PyObject], PyObject)
  92. def PyByteArray_Concat(space, a, b):
  93. """Concat bytearrays a and b and return a new bytearray with the result."""
  94. raise NotImplementedError
  95. @cpython_api([PyObject], Py_ssize_t, error=-1)
  96. def PyByteArray_Size(space, bytearray):
  97. """Return the size of bytearray after checking for a NULL pointer."""
  98. raise NotImplementedError
  99. @cpython_api([PyObject], rffi.CCHARP)
  100. def PyByteArray_AsString(space, bytearray):
  101. """Return the contents of bytearray as a char array after checking for a
  102. NULL pointer."""
  103. raise NotImplementedError
  104. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  105. def PyByteArray_Resize(space, bytearray, len):
  106. """Resize the internal buffer of bytearray to len."""
  107. raise NotImplementedError
  108. @cpython_api([PyObject], rffi.CCHARP)
  109. def PyByteArray_AS_STRING(space, bytearray):
  110. """Macro version of PyByteArray_AsString()."""
  111. raise NotImplementedError
  112. @cpython_api([PyObject], Py_ssize_t, error=-1)
  113. def PyByteArray_GET_SIZE(space, bytearray):
  114. """Macro version of PyByteArray_Size()."""
  115. raise NotImplementedError
  116. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  117. def PyCell_Check(space, ob):
  118. """Return true if ob is a cell object; ob must not be NULL."""
  119. raise NotImplementedError
  120. @cpython_api([PyObject], PyObject)
  121. def PyCell_New(space, ob):
  122. """Create and return a new cell object containing the value ob. The parameter may
  123. be NULL."""
  124. raise NotImplementedError
  125. @cpython_api([PyObject], PyObject)
  126. def PyCell_Get(space, cell):
  127. """Return the contents of the cell cell."""
  128. raise NotImplementedError
  129. @cpython_api([PyObject], PyObject)
  130. def PyCell_GET(space, cell):
  131. """Return the contents of the cell cell, but without checking that cell is
  132. non-NULL and a cell object."""
  133. borrow_from()
  134. raise NotImplementedError
  135. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  136. def PyCell_Set(space, cell, value):
  137. """Set the contents of the cell object cell to value. This releases the
  138. reference to any current content of the cell. value may be NULL. cell
  139. must be non-NULL; if it is not a cell object, -1 will be returned. On
  140. success, 0 will be returned."""
  141. raise NotImplementedError
  142. @cpython_api([PyObject, PyObject], lltype.Void)
  143. def PyCell_SET(space, cell, value):
  144. """Sets the value of the cell object cell to value. No reference counts are
  145. adjusted, and no checks are made for safety; cell must be non-NULL and must
  146. be a cell object."""
  147. raise NotImplementedError
  148. @cpython_api([PyObject, PyObject], rffi.INT_real, error=CANNOT_FAIL)
  149. def PyClass_IsSubclass(space, klass, base):
  150. """Return true if klass is a subclass of base. Return false in all other cases."""
  151. raise NotImplementedError
  152. @cpython_api([PyObject], rffi.INT_real, error=-1)
  153. def PyCodec_Register(space, search_function):
  154. """Register a new codec search function.
  155. As side effect, this tries to load the encodings package, if not yet
  156. done, to make sure that it is always first in the list of search functions."""
  157. raise NotImplementedError
  158. @cpython_api([PyObject, rffi.CCHARP, rffi.CCHARP], PyObject)
  159. def PyCodec_Encode(space, object, encoding, errors):
  160. """Generic codec based encoding API.
  161. object is passed through the encoder function found for the given
  162. encoding using the error handling method defined by errors. errors may
  163. be NULL to use the default method defined for the codec. Raises a
  164. LookupError if no encoder can be found."""
  165. raise NotImplementedError
  166. @cpython_api([PyObject, rffi.CCHARP, rffi.CCHARP], PyObject)
  167. def PyCodec_Decode(space, object, encoding, errors):
  168. """Generic codec based decoding API.
  169. object is passed through the decoder function found for the given
  170. encoding using the error handling method defined by errors. errors may
  171. be NULL to use the default method defined for the codec. Raises a
  172. LookupError if no encoder can be found."""
  173. raise NotImplementedError
  174. @cpython_api([rffi.CCHARP], PyObject)
  175. def PyCodec_Encoder(space, encoding):
  176. """Get an encoder function for the given encoding."""
  177. raise NotImplementedError
  178. @cpython_api([rffi.CCHARP], PyObject)
  179. def PyCodec_Decoder(space, encoding):
  180. """Get a decoder function for the given encoding."""
  181. raise NotImplementedError
  182. @cpython_api([rffi.CCHARP, PyObject, rffi.CCHARP], PyObject)
  183. def PyCodec_StreamReader(space, encoding, stream, errors):
  184. """Get a StreamReader factory function for the given encoding."""
  185. raise NotImplementedError
  186. @cpython_api([rffi.CCHARP, PyObject, rffi.CCHARP], PyObject)
  187. def PyCodec_StreamWriter(space, encoding, stream, errors):
  188. """Get a StreamWriter factory function for the given encoding."""
  189. raise NotImplementedError
  190. @cpython_api([rffi.CCHARP, PyObject], rffi.INT_real, error=-1)
  191. def PyCodec_RegisterError(space, name, error):
  192. """Register the error handling callback function error under the given name.
  193. This callback function will be called by a codec when it encounters
  194. unencodable characters/undecodable bytes and name is specified as the error
  195. parameter in the call to the encode/decode function.
  196. The callback gets a single argument, an instance of
  197. UnicodeEncodeError, UnicodeDecodeError or
  198. UnicodeTranslateError that holds information about the problematic
  199. sequence of characters or bytes and their offset in the original string (see
  200. unicodeexceptions for functions to extract this information). The
  201. callback must either raise the given exception, or return a two-item tuple
  202. containing the replacement for the problematic sequence, and an integer
  203. giving the offset in the original string at which encoding/decoding should be
  204. resumed.
  205. Return 0 on success, -1 on error."""
  206. raise NotImplementedError
  207. @cpython_api([rffi.CCHARP], PyObject)
  208. def PyCodec_LookupError(space, name):
  209. """Lookup the error handling callback function registered under name. As a
  210. special case NULL can be passed, in which case the error handling callback
  211. for "strict" will be returned."""
  212. raise NotImplementedError
  213. @cpython_api([PyObject], PyObject)
  214. def PyCodec_StrictErrors(space, exc):
  215. """Raise exc as an exception."""
  216. raise NotImplementedError
  217. @cpython_api([PyObject], PyObject)
  218. def PyCodec_IgnoreErrors(space, exc):
  219. """Ignore the unicode error, skipping the faulty input."""
  220. raise NotImplementedError
  221. @cpython_api([PyObject], PyObject)
  222. def PyCodec_ReplaceErrors(space, exc):
  223. """Replace the unicode encode error with ? or U+FFFD."""
  224. raise NotImplementedError
  225. @cpython_api([PyObject], PyObject)
  226. def PyCodec_XMLCharRefReplaceErrors(space, exc):
  227. """Replace the unicode encode error with XML character references."""
  228. raise NotImplementedError
  229. @cpython_api([PyObject], PyObject)
  230. def PyCodec_BackslashReplaceErrors(space, exc):
  231. r"""Replace the unicode encode error with backslash escapes (\x, \u and
  232. \U)."""
  233. raise NotImplementedError
  234. @cpython_api([Py_complex, Py_complex], Py_complex)
  235. def _Py_c_sum(space, left, right):
  236. """Return the sum of two complex numbers, using the C Py_complex
  237. representation."""
  238. raise NotImplementedError
  239. @cpython_api([Py_complex, Py_complex], Py_complex)
  240. def _Py_c_diff(space, left, right):
  241. """Return the difference between two complex numbers, using the C
  242. Py_complex representation."""
  243. raise NotImplementedError
  244. @cpython_api([Py_complex], Py_complex)
  245. def _Py_c_neg(space, complex):
  246. """Return the negation of the complex number complex, using the C
  247. Py_complex representation."""
  248. raise NotImplementedError
  249. @cpython_api([Py_complex, Py_complex], Py_complex)
  250. def _Py_c_prod(space, left, right):
  251. """Return the product of two complex numbers, using the C Py_complex
  252. representation."""
  253. raise NotImplementedError
  254. @cpython_api([Py_complex, Py_complex], Py_complex)
  255. def _Py_c_quot(space, dividend, divisor):
  256. """Return the quotient of two complex numbers, using the C Py_complex
  257. representation."""
  258. raise NotImplementedError
  259. @cpython_api([Py_complex, Py_complex], Py_complex)
  260. def _Py_c_pow(space, num, exp):
  261. """Return the exponentiation of num by exp, using the C Py_complex
  262. representation."""
  263. raise NotImplementedError
  264. @cpython_api([Py_complex], PyObject)
  265. def PyComplex_FromCComplex(space, v):
  266. """Create a new Python complex number object from a C Py_complex value."""
  267. raise NotImplementedError
  268. @cpython_api([rffi.CCHARP, rffi.CCHARPP], rffi.DOUBLE, error=CANNOT_FAIL)
  269. def PyOS_ascii_strtod(space, nptr, endptr):
  270. """Convert a string to a double. This function behaves like the Standard C
  271. function strtod() does in the C locale. It does this without changing the
  272. current locale, since that would not be thread-safe.
  273. PyOS_ascii_strtod() should typically be used for reading configuration
  274. files or other non-user input that should be locale independent.
  275. See the Unix man page strtod(2) for details.
  276. Use PyOS_string_to_double() instead."""
  277. raise NotImplementedError
  278. @cpython_api([rffi.CCHARP, rffi.SIZE_T, rffi.CCHARP, rffi.DOUBLE], rffi.CCHARP)
  279. def PyOS_ascii_formatd(space, buffer, buf_len, format, d):
  280. """Convert a double to a string using the '.' as the decimal
  281. separator. format is a printf()-style format string specifying the
  282. number format. Allowed conversion characters are 'e', 'E', 'f',
  283. 'F', 'g' and 'G'.
  284. The return value is a pointer to buffer with the converted string or NULL if
  285. the conversion failed.
  286. This function is removed in Python 2.7 and 3.1. Use PyOS_double_to_string()
  287. instead."""
  288. raise NotImplementedError
  289. @cpython_api([rffi.DOUBLE, lltype.Char, rffi.INT_real, rffi.INT_real, rffi.INTP], rffi.CCHARP)
  290. def PyOS_double_to_string(space, val, format_code, precision, flags, ptype):
  291. """Convert a double val to a string using supplied
  292. format_code, precision, and flags.
  293. format_code must be one of 'e', 'E', 'f', 'F',
  294. 'g', 'G' or 'r'. For 'r', the supplied precision
  295. must be 0 and is ignored. The 'r' format code specifies the
  296. standard repr() format.
  297. flags can be zero or more of the values Py_DTSF_SIGN,
  298. Py_DTSF_ADD_DOT_0, or Py_DTSF_ALT, or-ed together:
  299. Py_DTSF_SIGN means to always precede the returned string with a sign
  300. character, even if val is non-negative.
  301. Py_DTSF_ADD_DOT_0 means to ensure that the returned string will not look
  302. like an integer.
  303. Py_DTSF_ALT means to apply "alternate" formatting rules. See the
  304. documentation for the PyOS_snprintf() '#' specifier for
  305. details.
  306. If ptype is non-NULL, then the value it points to will be set to one of
  307. Py_DTST_FINITE, Py_DTST_INFINITE, or Py_DTST_NAN, signifying that
  308. val is a finite number, an infinite number, or not a number, respectively.
  309. The return value is a pointer to buffer with the converted string or
  310. NULL if the conversion failed. The caller is responsible for freeing the
  311. returned string by calling PyMem_Free().
  312. """
  313. raise NotImplementedError
  314. @cpython_api([rffi.CCHARP], rffi.DOUBLE, error=CANNOT_FAIL)
  315. def PyOS_ascii_atof(space, nptr):
  316. """Convert a string to a double in a locale-independent way.
  317. See the Unix man page atof(2) for details.
  318. Use PyOS_string_to_double() instead."""
  319. raise NotImplementedError
  320. @cpython_api([rffi.CCHARP, rffi.CCHARP], rffi.CCHARP)
  321. def PyOS_stricmp(space, s1, s2):
  322. """Case insensitive comparison of strings. The function works almost
  323. identically to strcmp() except that it ignores the case.
  324. """
  325. raise NotImplementedError
  326. @cpython_api([rffi.CCHARP, rffi.CCHARP, Py_ssize_t], rffi.CCHARP)
  327. def PyOS_strnicmp(space, s1, s2, size):
  328. """Case insensitive comparison of strings. The function works almost
  329. identically to strncmp() except that it ignores the case.
  330. """
  331. raise NotImplementedError
  332. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  333. def PyTZInfo_Check(space, ob):
  334. """Return true if ob is of type PyDateTime_TZInfoType or a subtype of
  335. PyDateTime_TZInfoType. ob must not be NULL.
  336. """
  337. raise NotImplementedError
  338. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  339. def PyTZInfo_CheckExact(space, ob):
  340. """Return true if ob is of type PyDateTime_TZInfoType. ob must not be
  341. NULL.
  342. """
  343. raise NotImplementedError
  344. @cpython_api([PyTypeObjectPtr, PyGetSetDef], PyObject)
  345. def PyDescr_NewGetSet(space, type, getset):
  346. raise NotImplementedError
  347. @cpython_api([PyTypeObjectPtr, PyMemberDef], PyObject)
  348. def PyDescr_NewMember(space, type, meth):
  349. raise NotImplementedError
  350. @cpython_api([PyTypeObjectPtr, wrapperbase, rffi.VOIDP], PyObject)
  351. def PyDescr_NewWrapper(space, type, wrapper, wrapped):
  352. raise NotImplementedError
  353. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  354. def PyDescr_IsData(space, descr):
  355. """Return true if the descriptor objects descr describes a data attribute, or
  356. false if it describes a method. descr must be a descriptor object; there is
  357. no error checking.
  358. """
  359. raise NotImplementedError
  360. @cpython_api([PyObject, PyObject], PyObject)
  361. def PyWrapper_New(space, w_d, w_self):
  362. raise NotImplementedError
  363. @cpython_api([PyObject, PyObject, rffi.INT_real], rffi.INT_real, error=-1)
  364. def PyDict_Merge(space, a, b, override):
  365. """Iterate over mapping object b adding key-value pairs to dictionary a.
  366. b may be a dictionary, or any object supporting PyMapping_Keys()
  367. and PyObject_GetItem(). If override is true, existing pairs in a
  368. will be replaced if a matching key is found in b, otherwise pairs will
  369. only be added if there is not a matching key in a. Return 0 on
  370. success or -1 if an exception was raised.
  371. """
  372. raise NotImplementedError
  373. @cpython_api([PyObject, PyObject, rffi.INT_real], rffi.INT_real, error=-1)
  374. def PyDict_MergeFromSeq2(space, a, seq2, override):
  375. """Update or merge into dictionary a, from the key-value pairs in seq2.
  376. seq2 must be an iterable object producing iterable objects of length 2,
  377. viewed as key-value pairs. In case of duplicate keys, the last wins if
  378. override is true, else the first wins. Return 0 on success or -1
  379. if an exception was raised. Equivalent Python (except for the return
  380. value):
  381. def PyDict_MergeFromSeq2(a, seq2, override):
  382. for key, value in seq2:
  383. if override or key not in a:
  384. a[key] = value
  385. """
  386. raise NotImplementedError
  387. @cpython_api([rffi.INT_real], PyObject)
  388. def PyErr_SetFromWindowsErr(space, ierr):
  389. """This is a convenience function to raise WindowsError. If called with
  390. ierr of 0, the error code returned by a call to GetLastError()
  391. is used instead. It calls the Win32 function FormatMessage() to retrieve
  392. the Windows description of error code given by ierr or GetLastError(),
  393. then it constructs a tuple object whose first item is the ierr value and whose
  394. second item is the corresponding error message (gotten from
  395. FormatMessage()), and then calls PyErr_SetObject(PyExc_WindowsError,
  396. object). This function always returns NULL. Availability: Windows.
  397. Return value: always NULL."""
  398. raise NotImplementedError
  399. @cpython_api([PyObject, rffi.INT_real], PyObject)
  400. def PyErr_SetExcFromWindowsErr(space, type, ierr):
  401. """Similar to PyErr_SetFromWindowsErr(), with an additional parameter
  402. specifying the exception type to be raised. Availability: Windows.
  403. Return value: always NULL."""
  404. raise NotImplementedError
  405. @cpython_api([rffi.INT_real, rffi.CCHARP], PyObject)
  406. def PyErr_SetFromWindowsErrWithFilename(space, ierr, filename):
  407. """Similar to PyErr_SetFromWindowsErr(), with the additional behavior that
  408. if filename is not NULL, it is passed to the constructor of
  409. WindowsError as a third parameter. Availability: Windows.
  410. Return value: always NULL."""
  411. raise NotImplementedError
  412. @cpython_api([PyObject, rffi.INT_real, rffi.CCHARP], PyObject)
  413. def PyErr_SetExcFromWindowsErrWithFilename(space, type, ierr, filename):
  414. """Similar to PyErr_SetFromWindowsErrWithFilename(), with an additional
  415. parameter specifying the exception type to be raised. Availability: Windows.
  416. Return value: always NULL."""
  417. raise NotImplementedError
  418. @cpython_api([PyObject, rffi.CCHARP, rffi.CCHARP, rffi.INT_real, rffi.CCHARP, PyObject], rffi.INT_real, error=-1)
  419. def PyErr_WarnExplicit(space, category, message, filename, lineno, module, registry):
  420. """Issue a warning message with explicit control over all warning attributes. This
  421. is a straightforward wrapper around the Python function
  422. warnings.warn_explicit(), see there for more information. The module
  423. and registry arguments may be set to NULL to get the default effect
  424. described there."""
  425. raise NotImplementedError
  426. @cpython_api([rffi.INT_real], rffi.INT_real, error=CANNOT_FAIL)
  427. def PySignal_SetWakeupFd(space, fd):
  428. """This utility function specifies a file descriptor to which a '\0' byte will
  429. be written whenever a signal is received. It returns the previous such file
  430. descriptor. The value -1 disables the feature; this is the initial state.
  431. This is equivalent to signal.set_wakeup_fd() in Python, but without any
  432. error checking. fd should be a valid file descriptor. The function should
  433. only be called from the main thread."""
  434. raise NotImplementedError
  435. @cpython_api([rffi.CCHARP, rffi.CCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  436. def PyUnicodeDecodeError_Create(space, encoding, object, length, start, end, reason):
  437. """Create a UnicodeDecodeError object with the attributes encoding,
  438. object, length, start, end and reason."""
  439. raise NotImplementedError
  440. @cpython_api([rffi.CCHARP, rffi.CWCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  441. def PyUnicodeEncodeError_Create(space, encoding, object, length, start, end, reason):
  442. """Create a UnicodeEncodeError object with the attributes encoding,
  443. object, length, start, end and reason."""
  444. raise NotImplementedError
  445. @cpython_api([rffi.CWCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  446. def PyUnicodeTranslateError_Create(space, object, length, start, end, reason):
  447. """Create a UnicodeTranslateError object with the attributes object,
  448. length, start, end and reason."""
  449. raise NotImplementedError
  450. @cpython_api([PyObject], PyObject)
  451. def PyUnicodeDecodeError_GetEncoding(space, exc):
  452. """Return the encoding attribute of the given exception object."""
  453. raise NotImplementedError
  454. @cpython_api([PyObject], PyObject)
  455. def PyUnicodeDecodeError_GetObject(space, exc):
  456. """Return the object attribute of the given exception object."""
  457. raise NotImplementedError
  458. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  459. def PyUnicodeDecodeError_GetStart(space, exc, start):
  460. """Get the start attribute of the given exception object and place it into
  461. *start. start must not be NULL. Return 0 on success, -1 on
  462. failure."""
  463. raise NotImplementedError
  464. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  465. def PyUnicodeDecodeError_SetStart(space, exc, start):
  466. """Set the start attribute of the given exception object to start. Return
  467. 0 on success, -1 on failure."""
  468. raise NotImplementedError
  469. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  470. def PyUnicodeDecodeError_GetEnd(space, exc, end):
  471. """Get the end attribute of the given exception object and place it into
  472. *end. end must not be NULL. Return 0 on success, -1 on
  473. failure."""
  474. raise NotImplementedError
  475. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  476. def PyUnicodeDecodeError_SetEnd(space, exc, end):
  477. """Set the end attribute of the given exception object to end. Return 0
  478. on success, -1 on failure."""
  479. raise NotImplementedError
  480. @cpython_api([PyObject], PyObject)
  481. def PyUnicodeDecodeError_GetReason(space, exc):
  482. """Return the reason attribute of the given exception object."""
  483. raise NotImplementedError
  484. @cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1)
  485. def PyUnicodeDecodeError_SetReason(space, exc, reason):
  486. """Set the reason attribute of the given exception object to reason. Return
  487. 0 on success, -1 on failure."""
  488. raise NotImplementedError
  489. @cpython_api([rffi.CCHARP], rffi.INT_real, error=1)
  490. def Py_EnterRecursiveCall(space, where):
  491. """Marks a point where a recursive C-level call is about to be performed.
  492. If USE_STACKCHECK is defined, this function checks if the the OS
  493. stack overflowed using PyOS_CheckStack(). In this is the case, it
  494. sets a MemoryError and returns a nonzero value.
  495. The function then checks if the recursion limit is reached. If this is the
  496. case, a RuntimeError is set and a nonzero value is returned.
  497. Otherwise, zero is returned.
  498. where should be a string such as " in instance check" to be
  499. concatenated to the RuntimeError message caused by the recursion depth
  500. limit."""
  501. raise NotImplementedError
  502. @cpython_api([], lltype.Void)
  503. def Py_LeaveRecursiveCall(space):
  504. """Ends a Py_EnterRecursiveCall(). Must be called once for each
  505. successful invocation of Py_EnterRecursiveCall()."""
  506. raise NotImplementedError
  507. @cpython_api([PyFileObject], lltype.Void)
  508. def PyFile_IncUseCount(space, p):
  509. """Increments the PyFileObject's internal use count to indicate
  510. that the underlying FILE* is being used.
  511. This prevents Python from calling f_close() on it from another thread.
  512. Callers of this must call PyFile_DecUseCount() when they are
  513. finished with the FILE*. Otherwise the file object will
  514. never be closed by Python.
  515. The GIL must be held while calling this function.
  516. The suggested use is to call this after PyFile_AsFile() and before
  517. you release the GIL:
  518. FILE *fp = PyFile_AsFile(p);
  519. PyFile_IncUseCount(p);
  520. /* ... */
  521. Py_BEGIN_ALLOW_THREADS
  522. do_something(fp);
  523. Py_END_ALLOW_THREADS
  524. /* ... */
  525. PyFile_DecUseCount(p);
  526. """
  527. raise NotImplementedError
  528. @cpython_api([PyFileObject], lltype.Void)
  529. def PyFile_DecUseCount(space, p):
  530. """Decrements the PyFileObject's internal unlocked_count member to
  531. indicate that the caller is done with its own use of the FILE*.
  532. This may only be called to undo a prior call to PyFile_IncUseCount().
  533. The GIL must be held while calling this function (see the example
  534. above).
  535. """
  536. raise NotImplementedError
  537. @cpython_api([PyFileObject, rffi.CCHARP], rffi.INT_real, error=0)
  538. def PyFile_SetEncoding(space, p, enc):
  539. """Set the file's encoding for Unicode output to enc. Return 1 on success and 0
  540. on failure.
  541. """
  542. raise NotImplementedError
  543. @cpython_api([PyFileObject, rffi.CCHARP, rffi.CCHARP], rffi.INT_real, error=0)
  544. def PyFile_SetEncodingAndErrors(space, p, enc, errors):
  545. """Set the file's encoding for Unicode output to enc, and its error
  546. mode to err. Return 1 on success and 0 on failure.
  547. """
  548. raise NotImplementedError
  549. @cpython_api([], PyObject)
  550. def PyFloat_GetInfo(space):
  551. """Return a structseq instance which contains information about the
  552. precision, minimum and maximum values of a float. It's a thin wrapper
  553. around the header file float.h.
  554. """
  555. raise NotImplementedError
  556. @cpython_api([], rffi.DOUBLE, error=CANNOT_FAIL)
  557. def PyFloat_GetMax(space):
  558. """Return the maximum representable finite float DBL_MAX as C double.
  559. """
  560. raise NotImplementedError
  561. @cpython_api([], rffi.DOUBLE, error=CANNOT_FAIL)
  562. def PyFloat_GetMin(space):
  563. """Return the minimum normalized positive float DBL_MIN as C double.
  564. """
  565. raise NotImplementedError
  566. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  567. def PyFloat_ClearFreeList(space):
  568. """Clear the float free list. Return the number of items that could not
  569. be freed.
  570. """
  571. raise NotImplementedError
  572. @cpython_api([rffi.CCHARP, PyFloatObject], lltype.Void)
  573. def PyFloat_AsString(space, buf, v):
  574. """Convert the argument v to a string, using the same rules as
  575. str(). The length of buf should be at least 100.
  576. This function is unsafe to call because it writes to a buffer whose
  577. length it does not know.
  578. Use PyObject_Str() or PyOS_double_to_string() instead."""
  579. raise NotImplementedError
  580. @cpython_api([rffi.CCHARP, PyFloatObject], lltype.Void)
  581. def PyFloat_AsReprString(space, buf, v):
  582. """Same as PyFloat_AsString, except uses the same rules as
  583. repr(). The length of buf should be at least 100.
  584. This function is unsafe to call because it writes to a buffer whose
  585. length it does not know.
  586. Use PyObject_Repr() or PyOS_double_to_string() instead."""
  587. raise NotImplementedError
  588. @cpython_api([PyObject, PyObject], PyObject)
  589. def PyFunction_New(space, code, globals):
  590. """Return a new function object associated with the code object code. globals
  591. must be a dictionary with the global variables accessible to the function.
  592. The function's docstring, name and __module__ are retrieved from the code
  593. object, the argument defaults and closure are set to NULL."""
  594. raise NotImplementedError
  595. @cpython_api([PyObject], PyObject)
  596. def PyFunction_GetGlobals(space, op):
  597. """Return the globals dictionary associated with the function object op."""
  598. borrow_from()
  599. raise NotImplementedError
  600. @cpython_api([PyObject], PyObject)
  601. def PyFunction_GetModule(space, op):
  602. """Return the __module__ attribute of the function object op. This is normally
  603. a string containing the module name, but can be set to any other object by
  604. Python code."""
  605. borrow_from()
  606. raise NotImplementedError
  607. @cpython_api([PyObject], PyObject)
  608. def PyFunction_GetDefaults(space, op):
  609. """Return the argument default values of the function object op. This can be a
  610. tuple of arguments or NULL."""
  611. borrow_from()
  612. raise NotImplementedError
  613. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  614. def PyFunction_SetDefaults(space, op, defaults):
  615. """Set the argument default values for the function object op. defaults must be
  616. Py_None or a tuple.
  617. Raises SystemError and returns -1 on failure."""
  618. raise NotImplementedError
  619. @cpython_api([PyObject], PyObject)
  620. def PyFunction_GetClosure(space, op):
  621. """Return the closure associated with the function object op. This can be NULL
  622. or a tuple of cell objects."""
  623. borrow_from()
  624. raise NotImplementedError
  625. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  626. def PyFunction_SetClosure(space, op, closure):
  627. """Set the closure associated with the function object op. closure must be
  628. Py_None or a tuple of cell objects.
  629. Raises SystemError and returns -1 on failure."""
  630. raise NotImplementedError
  631. @cpython_api([PyTypeObjectPtr, Py_ssize_t], PyObject)
  632. def PyObject_GC_NewVar(space, type, size):
  633. """Analogous to PyObject_NewVar() but for container objects with the
  634. Py_TPFLAGS_HAVE_GC flag set.
  635. This function used an int type for size. This might require
  636. changes in your code for properly supporting 64-bit systems."""
  637. raise NotImplementedError
  638. @cpython_api([PyObject, Py_ssize_t], PyObject)
  639. def PyObject_GC_Resize(space, op, newsize):
  640. """Resize an object allocated by PyObject_NewVar(). Returns the
  641. resized object or NULL on failure.
  642. This function used an int type for newsize. This might
  643. require changes in your code for properly supporting 64-bit systems."""
  644. raise NotImplementedError
  645. @cpython_api([PyObject], lltype.Void)
  646. def _PyObject_GC_TRACK(space, op):
  647. """A macro version of PyObject_GC_Track(). It should not be used for
  648. extension modules."""
  649. raise NotImplementedError
  650. @cpython_api([PyObject], lltype.Void)
  651. def _PyObject_GC_UNTRACK(space, op):
  652. """A macro version of PyObject_GC_UnTrack(). It should not be used for
  653. extension modules."""
  654. raise NotImplementedError
  655. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  656. def PyGen_Check(space, ob):
  657. """Return true if ob is a generator object; ob must not be NULL."""
  658. raise NotImplementedError
  659. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  660. def PyGen_CheckExact(space, ob):
  661. """Return true if ob's type is PyGen_Type is a generator object; ob must not
  662. be NULL."""
  663. raise NotImplementedError
  664. @cpython_api([PyFrameObject], PyObject)
  665. def PyGen_New(space, frame):
  666. """Create and return a new generator object based on the frame object. A
  667. reference to frame is stolen by this function. The parameter must not be
  668. NULL."""
  669. raise NotImplementedError
  670. @cpython_api([rffi.CCHARP, PyObject, PyObject, PyObject], PyObject)
  671. def PyImport_ImportModuleEx(space, name, globals, locals, fromlist):
  672. """Import a module. This is best described by referring to the built-in
  673. Python function __import__(), as the standard __import__() function calls
  674. this function directly.
  675. The return value is a new reference to the imported module or top-level package,
  676. or NULL with an exception set on failure (before Python 2.4, the module may
  677. still be created in this case). Like for __import__(), the return value
  678. when a submodule of a package was requested is normally the top-level package,
  679. unless a non-empty fromlist was given.
  680. Failing imports remove incomplete module objects.
  681. The function is an alias for PyImport_ImportModuleLevel() with
  682. -1 as level, meaning relative import."""
  683. raise NotImplementedError
  684. @cpython_api([rffi.CCHARP, PyObject, PyObject, PyObject, rffi.INT_real], PyObject)
  685. def PyImport_ImportModuleLevel(space, name, globals, locals, fromlist, level):
  686. """Import a module. This is best described by referring to the built-in Python
  687. function __import__(), as the standard __import__() function calls
  688. this function directly.
  689. The return value is a new reference to the imported module or top-level package,
  690. or NULL with an exception set on failure. Like for __import__(),
  691. the return value when a submodule of a package was requested is normally the
  692. top-level package, unless a non-empty fromlist was given.
  693. """
  694. raise NotImplementedError
  695. @cpython_api([], lltype.Signed, error=CANNOT_FAIL)
  696. def PyImport_GetMagicNumber(space):
  697. """Return the magic number for Python bytecode files (a.k.a. .pyc and
  698. .pyo files). The magic number should be present in the first four bytes
  699. of the bytecode file, in little-endian byte order."""
  700. raise NotImplementedError
  701. @cpython_api([PyObject], PyObject)
  702. def PyImport_GetImporter(space, path):
  703. """Return an importer object for a sys.path/pkg.__path__ item
  704. path, possibly by fetching it from the sys.path_importer_cache
  705. dict. If it wasn't yet cached, traverse sys.path_hooks until a hook
  706. is found that can handle the path item. Return None if no hook could;
  707. this tells our caller it should fall back to the built-in import mechanism.
  708. Cache the result in sys.path_importer_cache. Return a new reference
  709. to the importer object.
  710. """
  711. raise NotImplementedError
  712. @cpython_api([], lltype.Void)
  713. def _PyImport_Init(space):
  714. """Initialize the import mechanism. For internal use only."""
  715. raise NotImplementedError
  716. @cpython_api([], lltype.Void)
  717. def PyImport_Cleanup(space):
  718. """Empty the module table. For internal use only."""
  719. raise NotImplementedError
  720. @cpython_api([], lltype.Void)
  721. def _PyImport_Fini(space):
  722. """Finalize the import mechanism. For internal use only."""
  723. raise NotImplementedError
  724. @cpython_api([rffi.CCHARP, rffi.CCHARP], PyObject)
  725. def _PyImport_FindExtension(space, name, filename):
  726. """For internal use only."""
  727. raise NotImplementedError
  728. @cpython_api([rffi.CCHARP, rffi.CCHARP], PyObject)
  729. def _PyImport_FixupExtension(space, name, filename):
  730. """For internal use only."""
  731. raise NotImplementedError
  732. @cpython_api([rffi.CCHARP], rffi.INT_real, error=-1)
  733. def PyImport_ImportFrozenModule(space, name):
  734. """Load a frozen module named name. Return 1 for success, 0 if the
  735. module is not found, and -1 with an exception set if the initialization
  736. failed. To access the imported module on a successful load, use
  737. PyImport_ImportModule(). (Note the misnomer --- this function would
  738. reload the module if it was already imported.)"""
  739. raise NotImplementedError
  740. @cpython_api([rffi.CCHARP, rffi.VOIDP], rffi.INT_real, error=-1)
  741. def PyImport_AppendInittab(space, name, initfunc):
  742. """Add a single module to the existing table of built-in modules. This is a
  743. convenience wrapper around PyImport_ExtendInittab(), returning -1 if
  744. the table could not be extended. The new module can be imported by the name
  745. name, and uses the function initfunc as the initialization function called
  746. on the first attempted import. This should be called before
  747. Py_Initialize()."""
  748. raise NotImplementedError
  749. @cpython_api([_inittab], rffi.INT_real, error=-1)
  750. def PyImport_ExtendInittab(space, newtab):
  751. """Add a collection of modules to the table of built-in modules. The newtab
  752. array must end with a sentinel entry which contains NULL for the name
  753. field; failure to provide the sentinel value can result in a memory fault.
  754. Returns 0 on success or -1 if insufficient memory could be allocated to
  755. extend the internal table. In the event of failure, no modules are added to the
  756. internal table. This should be called before Py_Initialize()."""
  757. raise NotImplementedError
  758. @cpython_api([], lltype.Void)
  759. def Py_Initialize(space):
  760. """Initialize the Python interpreter. In an application embedding Python,
  761. this should be called before using any other Python/C API functions; with
  762. the exception of Py_SetProgramName(), PyEval_InitThreads(),
  763. PyEval_ReleaseLock(), and PyEval_AcquireLock(). This initializes the table
  764. of loaded modules (sys.modules), and creates the fundamental modules
  765. __builtin__, __main__ and sys. It also initializes the module search path
  766. (sys.path). It does not set sys.argv; use PySys_SetArgvEx() for that. This
  767. is a no-op when called for a second time (without calling Py_Finalize()
  768. first). There is no return value; it is a fatal error if the initialization
  769. fails."""
  770. raise NotImplementedError
  771. @cpython_api([rffi.INT_real], lltype.Void)
  772. def Py_InitializeEx(space, initsigs):
  773. """This function works like Py_Initialize() if initsigs is 1. If
  774. initsigs is 0, it skips initialization registration of signal handlers, which
  775. might be useful when Python is embedded.
  776. """
  777. raise NotImplementedError
  778. @cpython_api([], lltype.Void)
  779. def Py_Finalize(space):
  780. """Undo all initializations made by Py_Initialize() and subsequent use of
  781. Python/C API functions, and destroy all sub-interpreters (see
  782. Py_NewInterpreter() below) that were created and not yet destroyed since
  783. the last call to Py_Initialize(). Ideally, this frees all memory
  784. allocated by the Python interpreter. This is a no-op when called for a second
  785. time (without calling Py_Initialize() again first). There is no return
  786. value; errors during finalization are ignored.
  787. This function is provided for a number of reasons. An embedding application
  788. might want to restart Python without having to restart the application itself.
  789. An application that has loaded the Python interpreter from a dynamically
  790. loadable library (or DLL) might want to free all memory allocated by Python
  791. before unloading the DLL. During a hunt for memory leaks in an application a
  792. developer might want to free all memory allocated by Python before exiting from
  793. the application.
  794. Bugs and caveats: The destruction of modules and objects in modules is done
  795. in random order; this may cause destructors (__del__() methods) to fail
  796. when they depend on other objects (even functions) or modules. Dynamically
  797. loaded extension modules loaded by Python are not unloaded. Small amounts of
  798. memory allocated by the Python interpreter may not be freed (if you find a leak,
  799. please report it). Memory tied up in circular references between objects is not
  800. freed. Some memory allocated by extension modules may not be freed. Some
  801. extensions may not work properly if their initialization routine is called more
  802. than once; this can happen if an application calls Py_Initialize() and
  803. Py_Finalize() more than once."""
  804. raise NotImplementedError
  805. @cpython_api([rffi.CCHARP], lltype.Void)
  806. def Py_SetProgramName(space, name):
  807. """This function should be called before Py_Initialize() is called for the
  808. first time, if it is called at all. It tells the interpreter the value of
  809. the argv[0] argument to the main() function of the program. This is used by
  810. Py_GetPath() and some other functions below to find the Python run-time
  811. libraries relative to the interpreter executable. The default value is
  812. 'python'. The argument should point to a zero-terminated character string
  813. in static storage whose contents will not change for the duration of the
  814. program's execution. No code in the Python interpreter will change the
  815. contents of this storage."""
  816. raise NotImplementedError
  817. @cpython_api([], rffi.CCHARP)
  818. def Py_GetPrefix(space):
  819. """Return the prefix for installed platform-independent files. This is derived
  820. through a number of complicated rules from the program name set with
  821. Py_SetProgramName() and some environment variables; for example, if the
  822. program name is '/usr/local/bin/python', the prefix is '/usr/local'. The
  823. returned string points into static storage; the caller should not modify its
  824. value. This corresponds to the prefix variable in the top-level
  825. Makefile and the --prefix argument to the configure
  826. script at build time. The value is available to Python code as sys.prefix.
  827. It is only useful on Unix. See also the next function."""
  828. raise NotImplementedError
  829. @cpython_api([], rffi.CCHARP)
  830. def Py_GetExecPrefix(space):
  831. """Return the exec-prefix for installed platform-dependent files. This is
  832. derived through a number of complicated rules from the program name set with
  833. Py_SetProgramName() and some environment variables; for example, if the
  834. program name is '/usr/local/bin/python', the exec-prefix is
  835. '/usr/local'. The returned string points into static storage; the caller
  836. should not modify its value. This corresponds to the exec_prefix
  837. variable in the top-level Makefile and the --exec-prefix
  838. argument to the configure script at build time. The value is
  839. available to Python code as sys.exec_prefix. It is only useful on Unix.
  840. Background: The exec-prefix differs from the prefix when platform dependent
  841. files (such as executables and shared libraries) are installed in a different
  842. directory tree. In a typical installation, platform dependent files may be
  843. installed in the /usr/local/plat subtree while platform independent may
  844. be installed in /usr/local.
  845. Generally speaking, a platform is a combination of hardware and software
  846. families, e.g. Sparc machines running the Solaris 2.x operating system are
  847. considered the same platform, but Intel machines running Solaris 2.x are another
  848. platform, and Intel machines running Linux are yet another platform. Different
  849. major revisions of the same operating system generally also form different
  850. platforms. Non-Unix operating systems are a different story; the installation
  851. strategies on those systems are so different that the prefix and exec-prefix are
  852. meaningless, and set to the empty string. Note that compiled Python bytecode
  853. files are platform independent (but not independent from the Python version by
  854. which they were compiled!).
  855. System administrators will know how to configure the mount or
  856. automount programs to share /usr/local between platforms
  857. while having /usr/local/plat be a different filesystem for each
  858. platform."""
  859. raise NotImplementedError
  860. @cpython_api([], rffi.CCHARP)
  861. def Py_GetProgramFullPath(space):
  862. """Return the full program name of the Python executable; this is computed
  863. as a side-effect of deriving the default module search path from the program
  864. name (set by Py_SetProgramName() above). The returned string points into
  865. static storage; the caller should not modify its value. The value is
  866. available to Python code as sys.executable."""
  867. raise NotImplementedError
  868. @cpython_api([], rffi.CCHARP)
  869. def Py_GetPath(space):
  870. """Return the default module search path; this is computed from the program
  871. name (set by Py_SetProgramName() above) and some environment variables. The
  872. returned string consists of a series of directory names separated by a
  873. platform dependent delimiter character. The delimiter character is ':' on
  874. Unix and Mac OS X, ';' on Windows. The returned string points into static
  875. storage; the caller should not modify its value. The list sys.path is
  876. initialized with this value on interpreter startup; it can be (and usually
  877. is) modified later to change the search path for loading modules.
  878. XXX should give the exact rules"""
  879. raise NotImplementedError
  880. @cpython_api([], rffi.CCHARP)
  881. def Py_GetPlatform(space):
  882. """Return the platform identifier for the current platform. On Unix, this
  883. is formed from the"official" name of the operating system, converted to lower
  884. case, followed by the major revision number; e.g., for Solaris 2.x, which is
  885. also known as SunOS 5.x, the value is 'sunos5'. On Mac OS X, it is
  886. 'darwin'. On Windows, it is 'win'. The returned string points into
  887. static storage; the caller should not modify its value. The value is available
  888. to Python code as sys.platform."""
  889. raise NotImplementedError
  890. @cpython_api([], rffi.CCHARP)
  891. def Py_GetCopyright(space):
  892. """Return the official copyright string for the current Python version, for example
  893. 'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'
  894. The returned string points into static storage; the caller should not modify its
  895. value. The value is available to Python code as sys.copyright."""
  896. raise NotImplementedError
  897. @cpython_api([], rffi.CCHARP)
  898. def Py_GetCompiler(space):
  899. """Return an indication of the compiler used to build the current Python version,
  900. in square brackets, for example:
  901. "[GCC 2.7.2.2]"
  902. The returned string points into static storage; the caller should not modify its
  903. value. The value is available to Python code as part of the variable
  904. sys.version."""
  905. raise NotImplementedError
  906. @cpython_api([], rffi.CCHARP)
  907. def Py_GetBuildInfo(space):
  908. """Return information about the sequence number and build date and time of the
  909. current Python interpreter instance, for example
  910. "\#67, Aug 1 1997, 22:34:28"
  911. The returned string points into static storage; the caller should not modify its
  912. value. The value is available to Python code as part of the variable
  913. sys.version."""
  914. raise NotImplementedError
  915. @cpython_api([rffi.INT_real, rffi.CCHARPP, rffi.INT_real], lltype.Void)
  916. def PySys_SetArgvEx(space, argc, argv, updatepath):
  917. """Set sys.argv based on argc and argv. These parameters are similar to
  918. those passed to the program's main() function with the difference that the
  919. first entry should refer to the script file to be executed rather than the
  920. executable hosting the Python interpreter. If there isn't a script that
  921. will be run, the first entry in argv can be an empty string. If this
  922. function fails to initialize sys.argv, a fatal condition is signalled using
  923. Py_FatalError().
  924. If updatepath is zero, this is all the function does. If updatepath
  925. is non-zero, the function also modifies sys.path according to the
  926. following algorithm:
  927. If the name of an existing script is passed in argv[0], the absolute
  928. path of the directory where the script is located is prepended to
  929. sys.path.
  930. Otherwise (that is, if argc is 0 or argv[0] doesn't point
  931. to an existing file name), an empty string is prepended to
  932. sys.path, which is the same as prepending the current working
  933. directory (".").
  934. It is recommended that applications embedding the Python interpreter
  935. for purposes other than executing a single script pass 0 as updatepath,
  936. and update sys.path themselves if desired.
  937. See CVE-2008-5983.
  938. On versions before 2.6.6, you can achieve the same effect by manually
  939. popping the first sys.path element after having called
  940. PySys_SetArgv(), for example using:
  941. PyRun_SimpleString("import sys; sys.path.pop(0)\n");
  942. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
  943. check w/ Guido."""
  944. raise NotImplementedError
  945. @cpython_api([rffi.INT_real, rffi.CCHARPP], lltype.Void)
  946. def PySys_SetArgv(space, argc, argv):
  947. """This function works like PySys_SetArgvEx() with updatepath set to 1."""
  948. raise NotImplementedError
  949. @cpython_api([rffi.CCHARP], lltype.Void)
  950. def Py_SetPythonHome(space, home):
  951. """Set the default "home" directory, that is, the location of the standard
  952. Python libraries. See PYTHONHOME for the meaning of the
  953. argument string.
  954. The argument should point to a zero-terminated character string in static
  955. storage whose contents will not change for the duration of the program's
  956. execution. No code in the Python interpreter will change the contents of
  957. this storage."""
  958. raise NotImplementedError
  959. @cpython_api([], rffi.CCHARP)
  960. def Py_GetPythonHome(space):
  961. """Return the default "home", that is, the value set by a previous call to
  962. Py_SetPythonHome(), or the value of the PYTHONHOME
  963. environment variable if it is set."""
  964. raise NotImplementedError
  965. @cpython_api([], lltype.Void)
  966. def PyEval_ReInitThreads(space):
  967. """This function is called from PyOS_AfterFork() to ensure that newly
  968. created child processes don't hold locks referring to threads which
  969. are not running in the child process."""
  970. raise NotImplementedError
  971. @cpython_api([], PyInterpreterState)
  972. def PyInterpreterState_New(space):
  973. """Create a new interpreter state object. The global interpreter lock need not
  974. be held, but may be held if it is necessary to serialize calls to this
  975. function."""
  976. raise NotImplementedError
  977. @cpython_api([PyInterpreterState], lltype.Void)
  978. def PyInterpreterState_Clear(space, interp):
  979. """Reset all information in an interpreter state object. The global interpreter
  980. lock must be held."""
  981. raise NotImplementedError
  982. @cpython_api([PyInterpreterState], lltype.Void)
  983. def PyInterpreterState_Delete(space, interp):
  984. """Destroy an interpreter state object. The global interpreter lock need not be
  985. held. The interpreter state must have been reset with a previous call to
  986. PyInterpreterState_Clear()."""
  987. raise NotImplementedError
  988. @cpython_api([], PyObject)
  989. def PyThreadState_GetDict(space):
  990. """Return a dictionary in which extensions can store thread-specific state
  991. information. Each extension should use a unique key to use to store state in
  992. the dictionary. It is okay to call this function when no current thread state
  993. is available. If this function returns NULL, no exception has been raised and
  994. the caller should assume no current thread state is available.
  995. Previously this could only be called when a current thread is active, and NULL
  996. meant that an exception was raised."""
  997. borrow_from()
  998. raise NotImplementedError
  999. @cpython_api([lltype.Signed, PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1000. def PyThreadState_SetAsyncExc(space, id, exc):
  1001. """Asynchronously raise an exception in a thread. The id argument is the thread
  1002. id of the target thread; exc is the exception object to be raised. This
  1003. function does not steal any references to exc. To prevent naive misuse, you
  1004. must write your own C extension to call this. Must be called with the GIL held.
  1005. Returns the number of thread states modified; this is normally one, but will be
  1006. zero if the thread id isn't found. If exc is NULL, the pending
  1007. exception (if any) for the thread is cleared. This raises no exceptions.
  1008. """
  1009. raise NotImplementedError
  1010. @cpython_api([], lltype.Void)
  1011. def PyEval_AcquireLock(space):
  1012. """Acquire the global interpreter lock. The lock must have been created earlier.
  1013. If this thread already has the lock, a deadlock ensues.
  1014. This function does not change the current thread state. Please use
  1015. PyEval_RestoreThread() or PyEval_AcquireThread()
  1016. instead."""
  1017. raise NotImplementedError
  1018. @cpython_api([], lltype.Void)
  1019. def PyEval_ReleaseLock(space):
  1020. """Release the global interpreter lock. The lock must have been created earlier.
  1021. This function does not change the current thread state. Please use
  1022. PyEval_SaveThread() or PyEval_ReleaseThread()
  1023. instead."""
  1024. raise NotImplementedError
  1025. @cpython_api([], PyThreadState)
  1026. def Py_NewInterpreter(space):
  1027. """Create a new sub-interpreter. This is an (almost) totally separate
  1028. environment for the execution of Python code. In particular, the new
  1029. interpreter has separate, independent versions of all imported modules,
  1030. including the fundamental modules builtins, __main__ and sys. The table of
  1031. loaded modules (sys.modules) and the module search path (sys.path) are also
  1032. separate. The new environment has no sys.argv variable. It has new standard
  1033. I/O stream file objects sys.stdin, sys.stdout and sys.stderr (however these
  1034. refer to the same underlying file descriptors).
  1035. The return value points to the first thread state created in the new
  1036. sub-interpreter. This thread state is made in the current thread state.
  1037. Note that no actual thread is created; see the discussion of thread states
  1038. below. If creation of the new interpreter is unsuccessful, NULL is
  1039. returned; no exception is set since the exception state is stored in the
  1040. current thread state and there may not be a current thread state. (Like all
  1041. other Python/C API functions, the global interpreter lock must be held before
  1042. calling this function and is still held when it returns; however, unlike most
  1043. other Python/C API functions, there needn't be a current thread state on
  1044. entry.)
  1045. Extension modules are shared between (sub-)interpreters as follows: the first
  1046. time a particular extension is imported, it is initialized normally, and a
  1047. (shallow) copy of its module's dictionary is squirreled away. When the same
  1048. extension is imported by another (sub-)interpreter, a new module is initialized
  1049. and filled with the contents of this copy; the extension's init function is
  1050. not called. Note that this is different from what happens when an extension is
  1051. imported after the interpreter has been completely re-initialized by calling
  1052. Py_Finalize() and Py_Initialize(); in that case, the extension's
  1053. initmodule function is called again."""
  1054. raise NotImplementedError
  1055. @cpython_api([PyThreadState], lltype.Void)
  1056. def Py_EndInterpreter(space, tstate):
  1057. """Destroy the (sub-)interpreter represented by the given thread state. The
  1058. given thread state must be the current thread state. See the discussion of
  1059. thread states below. When the call returns, the current thread state is
  1060. NULL. All thread states associated with this interpreter are destroyed.
  1061. (The global interpreter lock must be held before calling this function and is
  1062. still held when it returns.) Py_Finalize() will destroy all sub-interpreters
  1063. that haven't been explicitly destroyed at that point."""
  1064. raise NotImplementedError
  1065. @cpython_api([Py_tracefunc, PyObject], lltype.Void)
  1066. def PyEval_SetProfile(space, func, obj):
  1067. """Set the profiler function to func. The obj parameter is passed to the
  1068. function as its first parameter, and may be any Python object, or NULL. If
  1069. the profile function needs to maintain state, using a different value for obj
  1070. for each thread provides a convenient and thread-safe place to store it. The
  1071. profile function is called for all monitored events except the line-number
  1072. events."""
  1073. raise NotImplementedError
  1074. @cpython_api([Py_tracefunc, PyObject], lltype.Void)
  1075. def PyEval_SetTrace(space, func, obj):
  1076. """Set the tracing function to func. This is similar to
  1077. PyEval_SetProfile(), except the tracing function does receive line-number
  1078. events."""
  1079. raise NotImplementedError
  1080. @cpython_api([PyObject], PyObject)
  1081. def PyEval_GetCallStats(space, self):
  1082. """Return a tuple of function call counts. There are constants defined for the
  1083. positions within the tuple:
  1084. Name
  1085. Value
  1086. PCALL_ALL
  1087. 0
  1088. PCALL_FUNCTION
  1089. 1
  1090. PCALL_FAST_FUNCTION
  1091. 2
  1092. PCALL_FASTER_FUNCTION
  1093. 3
  1094. PCALL_METHOD
  1095. 4
  1096. PCALL_BOUND_METHOD
  1097. 5
  1098. PCALL_CFUNCTION
  1099. 6
  1100. PCALL_TYPE
  1101. 7
  1102. PCALL_GENERATOR
  1103. 8
  1104. PCALL_OTHER
  1105. 9
  1106. PCALL_POP
  1107. 10
  1108. PCALL_FAST_FUNCTION means no argument tuple needs to be created.
  1109. PCALL_FASTER_FUNCTION means that the fast-path frame setup code is used.
  1110. If there is a method call where the call can be optimized by changing
  1111. the argument tuple and calling the function directly, it gets recorded
  1112. twice.
  1113. This function is only present if Python is compiled with CALL_PROFILE
  1114. defined."""
  1115. raise NotImplementedError
  1116. @cpython_api([PyInterpreterState], PyThreadState)
  1117. def PyInterpreterState_ThreadHead(space, interp):
  1118. """Return the a pointer to the first PyThreadState object in the list of
  1119. threads associated with the interpreter interp.
  1120. """
  1121. raise NotImplementedError
  1122. @cpython_api([PyThreadState], PyThreadState)
  1123. def PyThreadState_Next(space, tstate):
  1124. """Return the next thread state object after tstate from the list of all such
  1125. objects belonging to the same PyInterpreterState object.
  1126. """
  1127. raise NotImplementedError
  1128. @cpython_api([PyObject], rffi.ULONGLONG, error=-1)
  1129. def PyInt_AsUnsignedLongLongMask(space, io):
  1130. """Will first attempt to cast the object to a PyIntObject or
  1131. PyLongObject, if it is not already one, and then return its value as
  1132. unsigned long long, without checking for overflow.
  1133. """
  1134. raise NotImplementedError
  1135. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  1136. def PyInt_ClearFreeList(space):
  1137. """Clear the integer free list. Return the number of items that could not
  1138. be freed.
  1139. """
  1140. raise NotImplementedError
  1141. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1142. def PySeqIter_Check(space, op):
  1143. """Return true if the type of op is PySeqIter_Type.
  1144. """
  1145. raise NotImplementedError
  1146. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1147. def PyCallIter_Check(space, op):
  1148. """Return true if the type of op is PyCallIter_Type.
  1149. """
  1150. raise NotImplementedError
  1151. @cpython_api([rffi.SIZE_T], PyObject)
  1152. def PyLong_FromSize_t(space, v):
  1153. """Return a new PyLongObject object from a C size_t, or
  1154. NULL on failure.
  1155. """
  1156. raise NotImplementedError
  1157. @cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.INT_real], PyObject)
  1158. def PyLong_FromUnicode(space, u, length, base):
  1159. """Convert a sequence of Unicode digits to a Python long integer value. The first
  1160. parameter, u, points to the first character of the Unicode string, length
  1161. gives the number of characters, and base is the radix for the conversion. The
  1162. radix must be in the range [2, 36]; if it is out of range, ValueError
  1163. will be raised.
  1164. This function used an int for length. This might require
  1165. changes in your code for properly supporting 64-bit systems."""
  1166. raise NotImplementedError
  1167. @cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1)
  1168. def PyMapping_DelItemString(space, o, key):
  1169. """Remove the mapping for object key from the object o. Return -1 on
  1170. failure. This is equivalent to the Python statement del o[key]."""
  1171. raise NotImplementedError
  1172. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  1173. def PyMapping_DelItem(space, o, key):
  1174. """Remove the mapping for object key from the object o. Return -1 on
  1175. failure. This is equivalent to the Python statement del o[key]."""
  1176. raise NotImplementedError
  1177. @cpython_api([lltype.Signed, FILE, rffi.INT_real], lltype.Void)
  1178. def PyMarshal_WriteLongToFile(space, value, file, version):
  1179. """Marshal a long integer, value, to file. This will only write
  1180. the least-significant 32 bits of value; regardless of the size of the
  1181. native long type.
  1182. version indicates the file format."""
  1183. raise NotImplementedError
  1184. @cpython_api([PyObject, FILE, rffi.INT_real], lltype.Void)
  1185. def PyMarshal_WriteObjectToFile(space, value, file, version):
  1186. """Marshal a Python object, value, to file.
  1187. version indicates the file format."""
  1188. raise NotImplementedError
  1189. @cpython_api([PyObject, rffi.INT_real], PyObject)
  1190. def PyMarshal_WriteObjectToString(space, value, version):
  1191. """Return a string object containing the marshalled representation of value.
  1192. version indicates the file format."""
  1193. raise NotImplementedError
  1194. @cpython_api([FILE], lltype.Signed, error=CANNOT_FAIL)
  1195. def PyMarshal_ReadLongFromFile(space, file):
  1196. """Return a C long from the data stream in a FILE* opened
  1197. for reading. Only a 32-bit value can be read in using this function,
  1198. regardless of the native size of long."""
  1199. raise NotImplementedError
  1200. @cpython_api([FILE], rffi.INT_real, error=CANNOT_FAIL)
  1201. def PyMarshal_ReadShortFromFile(space, file):
  1202. """Return a C short from the data stream in a FILE* opened
  1203. for reading. Only a 16-bit value can be read in using this function,
  1204. regardless of the native size of short."""
  1205. raise NotImplementedError
  1206. @cpython_api([FILE], PyObject)
  1207. def PyMarshal_ReadObjectFromFile(space, file):
  1208. """Return a Python object from the data stream in a FILE* opened for
  1209. reading. On error, sets the appropriate exception (EOFError or
  1210. TypeError) and returns NULL."""
  1211. raise NotImplementedError
  1212. @cpython_api([FILE], PyObject)
  1213. def PyMarshal_ReadLastObjectFromFile(space, file):
  1214. """Return a Python object from the data stream in a FILE* opened for
  1215. reading. Unlike PyMarshal_ReadObjectFromFile(), this function
  1216. assumes that no further objects will be read from the file, allowing it to
  1217. aggressively load file data into memory so that the de-serialization can
  1218. operate from data in memory rather than reading a byte at a time from the
  1219. file. Only use these variant if you are certain that you won't be reading
  1220. anything else from the file. On error, sets the appropriate exception
  1221. (EOFError or TypeError) and returns NULL."""
  1222. raise NotImplementedError
  1223. @cpython_api([rffi.CCHARP, Py_ssize_t], PyObject)
  1224. def PyMarshal_ReadObjectFromString(space, string, len):
  1225. """Return a Python object from the data stream in a character buffer
  1226. containing len bytes pointed to by string. On error, sets the
  1227. appropriate exception (EOFError or TypeError) and returns
  1228. NULL.
  1229. This function used an int type for len. This might require
  1230. changes in your code for properly supporting 64-bit systems."""
  1231. raise NotImplementedError
  1232. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  1233. def PyMethod_ClearFreeList(space):
  1234. """Clear the free list. Return the total number of freed items.
  1235. """
  1236. raise NotImplementedError
  1237. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1238. def PyModule_CheckExact(space, p):
  1239. """Return true if p is a module object, but not a subtype of
  1240. PyModule_Type.
  1241. """
  1242. raise NotImplementedError
  1243. @cpython_api([rffi.CCHARP], PyObject)
  1244. def PyModule_New(space, name):
  1245. """Return a new module object with the __name__ attribute set to name. Only
  1246. the module's __doc__ and __name__ attributes are filled in; the caller is
  1247. responsible for providing a __file__ attribute."""
  1248. raise NotImplementedError
  1249. @cpython_api([PyObject], rffi.CCHARP)
  1250. def PyModule_GetFilename(space, module):
  1251. """Return the name of the file from which module was loaded using module's
  1252. __file__ attribute. If this is not defined, or if it is not a string, raise
  1253. SystemError and return NULL."""
  1254. raise NotImplementedError
  1255. @cpython_api([PyObject, rffi.INT], rffi.INT_real, error=-1)
  1256. def PyModule_AddIntMacro(space, module, macro):
  1257. """Add an int constant to module. The name and the value are taken from
  1258. macro. For example PyModule_AddConstant(module, AF_INET) adds the int
  1259. constant AF_INET with the value of AF_INET to module.
  1260. Return -1 on error, 0 on success.
  1261. """
  1262. raise NotImplementedError
  1263. @cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1)
  1264. def PyModule_AddStringMacro(space, module, macro):
  1265. """Add a string constant to module.
  1266. """
  1267. raise NotImplementedError
  1268. @cpython_api([PyObjectP, PyObjectP], rffi.INT_real, error=-1)
  1269. def PyNumber_Coerce(space, p1, p2):
  1270. """This function takes the addresses of two variables of type PyObject*. If
  1271. the objects pointed to by *p1 and *p2 have the same type, increment their
  1272. reference count and return 0 (success). If the objects can be converted to a
  1273. common numeric type, replace *p1 and *p2 by their converted value (with
  1274. 'new' reference counts), and return 0. If no conversion is possible, or if
  1275. some other error occurs, return -1 (failure) and don't increment the
  1276. reference counts. The call PyNumber_Coerce(&o1, &o2) is equivalent to the
  1277. Python statement o1, o2 = coerce(o1, o2)."""
  1278. raise NotImplementedError
  1279. @cpython_api([PyObjectP, PyObjectP], rffi.INT_real, error=-1)
  1280. def PyNumber_CoerceEx(space, p1, p2):
  1281. """This function is similar to PyNumber_Coerce(), except that it returns
  1282. 1 when the conversion is not possible and when no error is raised.
  1283. Reference counts are still not increased in this case."""
  1284. raise NotImplementedError
  1285. @cpython_api([PyObject, rffi.INT_real], PyObject)
  1286. def PyNumber_ToBase(space, n, base):
  1287. """Returns the integer n converted to base as a string with a base
  1288. marker of '0b', '0o', or '0x' if applicable. When
  1289. base is not 2, 8, 10, or 16, the format is 'x#num' where x is the
  1290. base. If n is not an int object, it is converted with
  1291. PyNumber_Index() first.
  1292. """
  1293. raise NotImplementedError
  1294. @cpython_api([PyObject], PyObject)
  1295. def PyObject_Bytes(space, o):
  1296. """Compute a bytes representation of object o. In 2.x, this is just a alias
  1297. for PyObject_Str()."""
  1298. raise NotImplementedError
  1299. @cpython_api([], PyFrameObject)
  1300. def PyEval_GetFrame(space):
  1301. """Return the current thread state's frame, which is NULL if no frame is
  1302. currently executing."""
  1303. borrow_from()
  1304. raise NotImplementedError
  1305. @cpython_api([PyFrameObject], rffi.INT_real, error=CANNOT_FAIL)
  1306. def PyFrame_GetLineNumber(space, frame):
  1307. """Return the line number that frame is currently executing."""
  1308. raise NotImplementedError
  1309. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  1310. def PyEval_GetRestricted(space):
  1311. """If there is a current frame and it is executing in restricted mode, return true,
  1312. otherwise false."""
  1313. raise NotImplementedError
  1314. @cpython_api([PyObject], rffi.CCHARP)
  1315. def PyEval_GetFuncName(space, func):
  1316. """Return the name of func if it is a function, class or instance object, else the
  1317. name of funcs type."""
  1318. raise NotImplementedError
  1319. @cpython_api([PyObject], rffi.CCHARP)
  1320. def PyEval_GetFuncDesc(space, func):
  1321. """Return a description string, depending on the type of func.
  1322. Return values include "()" for functions and methods, " constructor",
  1323. " instance", and " object". Concatenated with the result of
  1324. PyEval_GetFuncName(), the result will be a description of
  1325. func."""
  1326. raise NotImplementedError
  1327. @cpython_api([PyObject, PyObject], PyObject)
  1328. def PySequence_InPlaceConcat(space, o1, o2):
  1329. """Return the concatenation of o1 and o2 on success, and NULL on failure.
  1330. The operation is done in-place when o1 supports it. This is the equivalent
  1331. of the Python expression o1 += o2."""
  1332. raise NotImplementedError
  1333. @cpython_api([PyObject, Py_ssize_t], PyObject)
  1334. def PySequence_InPlaceRepeat(space, o, count):
  1335. """Return the result of repeating sequence object o count times, or NULL on
  1336. failure. The operation is done in-place when o supports it. This is the
  1337. equivalent of the Python expression o *= count.
  1338. This function used an int type for count. This might require
  1339. changes in your code for properly supporting 64-bit systems."""
  1340. raise NotImplementedError
  1341. @cpython_api([PyObject, PyObject], Py_ssize_t, error=-1)
  1342. def PySequence_Count(space, o, value):
  1343. """Return the number of occurrences of value in o, that is, return the number
  1344. of keys for which o[key] == value. On failure, return -1. This is
  1345. equivalent to the Python expression o.count(value).
  1346. This function returned an int type. This might require changes
  1347. in your code for properly supporting 64-bit systems."""
  1348. raise NotImplementedError
  1349. @cpython_api([PyObject], PyObjectP)
  1350. def PySequence_Fast_ITEMS(space, o):
  1351. """Return the underlying array of PyObject pointers. Assumes that o was returned
  1352. by PySequence_Fast() and o is not NULL.
  1353. Note, if a list gets resized, the reallocation may relocate the items array.
  1354. So, only use the underlying array pointer in contexts where the sequence
  1355. cannot change.
  1356. """
  1357. raise NotImplementedError
  1358. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1359. def PyFrozenSet_Check(space, p):
  1360. """Return true if p is a frozenset object or an instance of a
  1361. subtype.
  1362. """
  1363. raise NotImplementedError
  1364. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1365. def PyAnySet_Check(space, p):
  1366. """Return true if p is a set object, a frozenset object, or an
  1367. instance of a subtype."""
  1368. raise NotImplementedError
  1369. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1370. def PyAnySet_CheckExact(space, p):
  1371. """Return true if p is a set object or a frozenset object but
  1372. not an instance of a subtype."""
  1373. raise NotImplementedError
  1374. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1375. def PyFrozenSet_CheckExact(space, p):
  1376. """Return true if p is a frozenset object but not an instance of a
  1377. subtype."""
  1378. raise NotImplementedError
  1379. @cpython_api([PyObject], PyObject)
  1380. def PyFrozenSet_New(space, iterable):
  1381. """Return a new frozenset containing objects returned by the iterable.
  1382. The iterable may be NULL to create a new empty frozenset. Return the new
  1383. set on success or NULL on failure. Raise TypeError if iterable is
  1384. not actually iterable.
  1385. Now guaranteed to return a brand-new frozenset. Formerly,
  1386. frozensets of zero-length were a singleton. This got in the way of
  1387. building-up new frozensets with PySet_Add()."""
  1388. raise NotImplementedError
  1389. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, rffi.CCHARP], PyObject)
  1390. def PyString_Decode(space, s, size, encoding, errors):
  1391. """Create an object by decoding size bytes of the encoded buffer s using the
  1392. codec registered for encoding. encoding and errors have the same meaning
  1393. as the parameters of the same name in the unicode() built-in function.
  1394. The codec to be used is looked up using the Python codec registry. Return
  1395. NULL if an exception was raised by the codec.
  1396. This function is not available in 3.x and does not have a PyBytes alias.
  1397. This function used an int type for size. This might require
  1398. changes in your code for properly supporting 64-bit systems."""
  1399. raise NotImplementedError
  1400. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, rffi.CCHARP], PyObject)
  1401. def PyString_Encode(space, s, size, encoding, errors):
  1402. """Encode the char buffer of the given size by passing it to the codec
  1403. registered for encoding and return a Python object. encoding and errors
  1404. have the same meaning as the parameters of the same name in the string
  1405. encode() method. The codec to be used is looked up using the Python codec
  1406. registry. Return NULL if an exception was raised by the codec.
  1407. This function is not available in 3.x and does not have a PyBytes alias.
  1408. This function used an int type for size. This might require
  1409. changes in your code for properly supporting 64-bit systems."""
  1410. raise NotImplementedError
  1411. @cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=CANNOT_FAIL)
  1412. def Py_FdIsInteractive(space, fp, filename):
  1413. """Return true (nonzero) if the standard I/O file fp with name filename is
  1414. deemed interactive. This is the case for files for which isatty(fileno(fp))
  1415. is true. If the global flag Py_InteractiveFlag is true, this function
  1416. also returns true if the filename pointer is NULL or if the name is equal to
  1417. one of the strings '<stdin>' or '???'."""
  1418. raise NotImplementedError
  1419. @cpython_api([], lltype.Void)
  1420. def PyOS_AfterFork(space):
  1421. """Function to update some internal state after a process fork; this should be
  1422. called in the new process if the Python interpreter will continue to be used.
  1423. If a new executable is loaded into the new process, this function does not need
  1424. to be called."""
  1425. raise NotImplementedError
  1426. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  1427. def PyOS_CheckStack(space):
  1428. """Return true when the interpreter runs out of stack space. This is a reliable
  1429. check, but is only available when USE_STACKCHECK is defined (currently
  1430. on Windows using the Microsoft Visual C++ compiler). USE_STACKCHECK
  1431. will be defined automatically; you should never change the definition in your
  1432. own code."""
  1433. raise NotImplementedError
  1434. @cpython_api([rffi.CCHARP, FILE], FILE)
  1435. def PySys_GetFile(space, name, default):
  1436. """Return the FILE* associated with the object name in the
  1437. sys module, or def if name is not in the module or is not associated
  1438. with a FILE*."""
  1439. raise NotImplementedError
  1440. @cpython_api([], lltype.Void)
  1441. def PySys_ResetWarnOptions(space):
  1442. """Reset sys.warnoptions to an empty list."""
  1443. raise NotImplementedError
  1444. @cpython_api([rffi.CCHARP], lltype.Void)
  1445. def PySys_AddWarnOption(space, s):
  1446. """Append s to sys.warnoptions."""
  1447. raise NotImplementedError
  1448. @cpython_api([rffi.CCHARP], lltype.Void)
  1449. def PySys_SetPath(space, path):
  1450. """Set sys.path to a list object of paths found in path which should
  1451. be a list of paths separated with the platform's search path delimiter
  1452. (: on Unix, ; on Windows)."""
  1453. raise NotImplementedError
  1454. @cpython_api([rffi.INT_real], lltype.Void)
  1455. def Py_Exit(space, status):
  1456. """Exit the current process. This calls Py_Finalize() and then calls the
  1457. standard C library function exit(status)."""
  1458. raise NotImplementedError
  1459. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  1460. def PyTuple_ClearFreeList(space):
  1461. """Clear the free list. Return the total number of freed items.
  1462. """
  1463. raise NotImplementedError
  1464. @cpython_api([], rffi.UINT, error=CANNOT_FAIL)
  1465. def PyType_ClearCache(space):
  1466. """Clear the internal lookup cache. Return the current version tag.
  1467. """
  1468. raise NotImplementedError
  1469. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1470. def PyType_IS_GC(space, o):
  1471. """Return true if the type object includes support for the cycle detector; this
  1472. tests the type flag Py_TPFLAGS_HAVE_GC.
  1473. """
  1474. raise NotImplementedError
  1475. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  1476. def PyUnicode_ClearFreeList(space):
  1477. """Clear the free list. Return the total number of freed items.
  1478. """
  1479. raise NotImplementedError
  1480. @cpython_api([rffi.CCHARP], PyObject)
  1481. def PyUnicode_FromFormat(space, format):
  1482. """Take a C printf()-style format string and a variable number of
  1483. arguments, calculate the size of the resulting Python unicode string and return
  1484. a string with the values formatted into it. The variable arguments must be C
  1485. types and must correspond exactly to the format characters in the format
  1486. string. The following format characters are allowed:
  1487. Format Characters
  1488. Type
  1489. Comment
  1490. %%
  1491. n/a
  1492. The literal % character.
  1493. %c
  1494. int
  1495. A single character,
  1496. represented as an C int.
  1497. %d
  1498. int
  1499. Exactly equivalent to
  1500. printf("%d").
  1501. %u
  1502. unsigned int
  1503. Exactly equivalent to
  1504. printf("%u").
  1505. %ld
  1506. long
  1507. Exactly equivalent to
  1508. printf("%ld").
  1509. %lu
  1510. unsigned long
  1511. Exactly equivalent to
  1512. printf("%lu").
  1513. %zd
  1514. Py_ssize_t
  1515. Exactly equivalent to
  1516. printf("%zd").
  1517. %zu
  1518. size_t
  1519. Exactly equivalent to
  1520. printf("%zu").
  1521. %i
  1522. int
  1523. Exactly equivalent to
  1524. printf("%i").
  1525. %x
  1526. int
  1527. Exactly equivalent to
  1528. printf("%x").
  1529. %s
  1530. char*
  1531. A null-terminated C character
  1532. array.
  1533. %p
  1534. void*
  1535. The hex representation of a C
  1536. pointer. Mostly equivalent to
  1537. printf("%p") except that
  1538. it is guaranteed to start with
  1539. the literal 0x regardless
  1540. of what the platform's
  1541. printf yields.
  1542. %U
  1543. PyObject*
  1544. A unicode object.
  1545. %V
  1546. PyObject*, char *
  1547. A unicode object (which may be
  1548. NULL) and a null-terminated
  1549. C character array as a second
  1550. parameter (which will be used,
  1551. if the first parameter is
  1552. NULL).
  1553. %S
  1554. PyObject*
  1555. The result of calling
  1556. PyObject_Unicode().
  1557. %R
  1558. PyObject*
  1559. The result of calling
  1560. PyObject_Repr().
  1561. An unrecognized format character causes all the rest of the format string to be
  1562. copied as-is to the result string, and any extra arguments discarded.
  1563. """
  1564. raise NotImplementedError
  1565. @cpython_api([rffi.CCHARP, va_list], PyObject)
  1566. def PyUnicode_FromFormatV(space, format, vargs):
  1567. """Identical to PyUnicode_FromFormat() except that it takes exactly two
  1568. arguments.
  1569. """
  1570. raise NotImplementedError
  1571. @cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.CCHARP, rffi.CCHARP], PyObject)
  1572. def PyUnicode_Encode(space, s, size, encoding, errors):
  1573. """Encode the Py_UNICODE buffer of the given size and return a Python
  1574. string object. encoding and errors have the same meaning as the parameters
  1575. of the same name in the Unicode encode() method. The codec to be used is
  1576. looked up using the Python codec registry. Return NULL if an exception was
  1577. raised by the codec.
  1578. This function used an int type for size. This might require
  1579. changes in your code for properly supporting 64-bit systems."""
  1580. raise NotImplementedError
  1581. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, Py_ssize_t], PyObject)
  1582. def PyUnicode_DecodeUTF8Stateful(space, s, size, errors, consumed):
  1583. """If consumed is NULL, behave like PyUnicode_DecodeUTF8(). If
  1584. consumed is not NULL, trailing incomplete UTF-8 byte sequences will not be
  1585. treated as an error. Those bytes will not be decoded and the number of bytes
  1586. that have been decoded will be stored in consumed.
  1587. This function used an int type for size. This might require
  1588. changes in your code for properly supporting 64-bit systems."""
  1589. raise NotImplementedError
  1590. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, rffi.INTP, Py_ssize_t], PyObject)
  1591. def PyUnicode_DecodeUTF32Stateful(space, s, size, errors, byteorder, consumed):
  1592. """If consumed is NULL, behave like PyUnicode_DecodeUTF32(). If
  1593. consumed is not NULL, PyUnicode_DecodeUTF32Stateful() will not treat
  1594. trailing incomplete UTF-32 byte sequences (such as a number of bytes not divisible
  1595. by four) as an error. Those bytes will not be decoded and the number of bytes
  1596. that have been decoded will be stored in consumed.
  1597. """
  1598. raise NotImplementedError
  1599. @cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.CCHARP, rffi.INT_real], PyObject)
  1600. def PyUnicode_EncodeUTF32(space, s, size, errors, byteorder):
  1601. """Return a Python bytes object holding the UTF-32 encoded value of the Unicode
  1602. data in s. Output is written according to the following byte order:
  1603. byteorder == -1: little endian
  1604. byteorder == 0: native byte order (writes a BOM mark)
  1605. byteorder == 1: big endian
  1606. If byteorder is 0, the output string will always start with the Unicode BOM
  1607. mark (U+FEFF). In the other two modes, no BOM mark is prepended.
  1608. If Py_UNICODE_WIDE is not defined, surrogate pairs will be output
  1609. as a single codepoint.
  1610. Return NULL if an exception was raised by the codec.
  1611. """
  1612. raise NotImplementedError
  1613. @cpython_api([PyObject], PyObject)
  1614. def PyUnicode_AsUTF32String(space, unicode):
  1615. """Return a Python string using the UTF-32 encoding in native byte order. The
  1616. string always starts with a BOM mark. Error handling is "strict". Return
  1617. NULL if an exception was raised by the codec.
  1618. """
  1619. raise NotImplementedError
  1620. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, rffi.INTP, Py_ssize_t], PyObject)
  1621. def PyUnicode_DecodeUTF16Stateful(space, s, size, errors, byteorder, consumed):
  1622. """If consumed is NULL, behave like PyUnicode_DecodeUTF16(). If
  1623. consumed is not NULL, PyUnicode_DecodeUTF16Stateful() will not treat
  1624. trailing incomplete UTF-16 byte sequences (such as an odd number of bytes or a
  1625. split surrogate pair) as an error. Those bytes will not be decoded and the
  1626. number of bytes that have been decoded will be stored in consumed.
  1627. This function used an int type for size and an int *
  1628. type for consumed. This might require changes in your code for
  1629. properly supporting 64-bit systems."""
  1630. raise NotImplementedError
  1631. @cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.CCHARP, rffi.INT_real], PyObject)
  1632. def PyUnicode_EncodeUTF16(space, s, size, errors, byteorder):
  1633. """Return a Python string object holding the UTF-16 encoded value of the Unicode
  1634. data in s. Output is written according to the following byte order:
  1635. byteorder == -1: little endian
  1636. byteorder == 0: native byte order (writes a BOM mark)
  1637. byteorder == 1: big endian
  1638. If byteorder is 0, the output string will always start with the Unicode BOM
  1639. mark (U+FEFF). In the other two modes, no BOM mark is prepended.
  1640. If Py_UNICODE_WIDE is defined, a single Py_UNICODE value may get
  1641. represented as a surrogate pair. If it is not defined, each Py_UNICODE
  1642. values is interpreted as an UCS-2 character.
  1643. Return NULL if an exception was raised by the codec.
  1644. This function used an int type for size. This might require
  1645. changes in your code for properly supporting 64-bit systems."""
  1646. raise NotImplementedError
  1647. @cpython_api([PyObject], PyObject)
  1648. def PyUnicode_AsUTF16String(space, unicode):
  1649. """Return a Python string using the UTF-16 encoding in native byte order. The
  1650. string always starts with a BOM mark. Error handling is "strict". Return
  1651. NULL if an exception was raised by the codec."""
  1652. raise NotImplementedError
  1653. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP], PyObject)
  1654. def PyUnicode_DecodeUTF7(space, s, size, errors):
  1655. """Create a Unicode object by decoding size bytes of the UTF-7 encoded string
  1656. s. Return NULL if an exception was raised by the codec."""
  1657. raise NotImplementedError
  1658. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP, Py_ssize_t], PyObject)
  1659. def PyUnicode_DecodeUTF7Stateful(space, s, size, errors, consumed):
  1660. """If consumed is NULL, behave like PyUnicode_DecodeUTF7(). If
  1661. consumed is not NULL, trailing incomplete UTF-7 base-64 sections will not
  1662. be treated as an error. Those bytes will not be decoded and the number of
  1663. bytes that have been decoded will be stored in consumed."""
  1664. raise NotImplementedError
  1665. @cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.INT_real, rffi.INT_real, rffi.CCHARP], PyObject)
  1666. def PyUnicode_EncodeUTF7(space, s, size, base64SetO, base64WhiteSpace, errors):
  1667. """Encode the Py_UNICODE buffer of the given size using UTF-7 and
  1668. return a Python bytes object. Return NULL if an exception was raised by
  1669. the codec.
  1670. If base64SetO is nonzero, "Set O" (punctuation that has no otherwise
  1671. special meaning) will be encoded in base-64. If base64WhiteSpace is
  1672. nonzero, whitespace will be encoded in base-64. Both are set to zero for the
  1673. Python "utf-7" codec."""
  1674. raise NotImplementedError
  1675. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP], PyObject)
  1676. def PyUnicode_DecodeUnicodeEscape(space, s, size, errors):
  1677. """Create a Unicode object by decoding size bytes of the Unicode-Escape encoded
  1678. string s. Return NULL if an exception was raised by the codec.
  1679. This function used an int type for size. This might require
  1680. changes in your code for properly supporting 64-bit systems."""
  1681. raise NotImplementedError
  1682. @cpython_api([rffi.CWCHARP, Py_ssize_t], PyObject)
  1683. def PyUnicode_EncodeUnicodeEscape(space, s, size):
  1684. """Encode the Py_UNICODE buffer of the given size using Unicode-Escape and
  1685. return a Python string object. Return NULL if an exception was raised by the
  1686. codec.
  1687. This function used an int type for size. This might require
  1688. changes in your code for properly supporting 64-bit systems."""
  1689. raise NotImplementedError
  1690. @cpython_api([rffi.CCHARP, Py_ssize_t, rffi.CCHARP], PyObject)
  1691. def PyUnicode_DecodeRawUnicodeEscape(space, s, size, errors):
  1692. """Create a Unicode object by decoding size bytes of the Raw-Unicode-Escape
  1693. encoded string s. Return NULL if an exception was raised by the codec.
  1694. This function used an int type for size. This might require
  1695. changes in your code for properly supporting 64-bit systems."""
  1696. raise NotImplementedError
  1697. @cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.CCHARP], PyObject)
  1698. def PyUnicode_EncodeRawUnicodeEscape(space, s, size, errors):
  1699. """Encode the Py_UNICODE buffer of the given size using Raw-Unicode-Escape
  1700. and return a Python string object. Return NULL if an exception was raised by
  1701. the codec.
  1702. This function used an int type for size. This might require
  1703. changes in your code for properly supporting 64-bit systems."""
  1704. raise NotImplementedError
  1705. @cpython_api([PyObject], PyObject)
  1706. def PyUnicode_AsRawUnicodeEscapeString(space, unicode):
  1707. """Encode a Unicode object using Raw-Unicode-Escape and return the result as
  1708. Python string object. Error handling is "strict". Return NULL if an exception
  1709. was raised by the codec."""
  1710. raise NotImplementedError
  1711. @cpython_api([rffi.CCHARP, Py_ssize_t, PyObject, rffi.CCHARP], PyObject)
  1712. def PyUnicode_DecodeCharmap(space, s, size, mapping, errors):
  1713. """Create a Unicode object by decoding size bytes of the encoded string s using
  1714. the given mapping object. Return NULL if an exception was raised by the
  1715. codec. If mapping is NULL latin-1 decoding will be done. Else it can be a
  1716. dictionary mapping byte or a unicode string, which is treated as a lookup table.
  1717. Byte values greater that the length of the string and U+FFFE "characters" are
  1718. treated as "undefined mapping".
  1719. Allowed unicode string as mapping argument.
  1720. This function used an int type for size. This might require
  1721. changes in your code for properly supporting 64-bit systems."""
  1722. raise NotImplementedError
  1723. @cpython_api([rffi.CWCHARP, Py_ssize_t, PyObject, rffi.CCHARP], PyObject)
  1724. def PyUnicode_EncodeCharmap(space, s, size, mapping, errors):
  1725. """Encode the Py_UNICODE buffer of the given size using the given
  1726. mapping object and return a Python string object. Return NULL if an
  1727. exception was raised by the codec.
  1728. This function used an int type for size. This might require
  1729. changes in your code for properly supporting 64-bit systems."""
  1730. raise NotImplementedError
  1731. @cpython_api([PyObject, PyObject], PyObject)
  1732. def PyUnicode_AsCharmapString(space, unicode, mapping):
  1733. """Encode a Unicode object using the given mapping object and return the result
  1734. as Python string object. Error handling is "strict". Return NULL if an
  1735. exception was raised by the codec."""
  1736. raise NotImplementedError
  1737. @cpython_api([rffi.CWCHARP, Py_ssize_t, PyObject, rffi.CCHARP], PyObject)
  1738. def PyUnicode_TranslateCharmap(space, s, size, table, errors):
  1739. """Translate a Py_UNICODE buffer of the given length by applying a
  1740. character mapping table to it and return the resulting Unicode object. Return
  1741. NULL when an exception was raised by the codec.
  1742. The mapping table must map Unicode ordinal integers to Unicode ordinal
  1743. integers or None (causing deletion of the character).
  1744. Mapping tables need only provide the __getitem__() interface; dictionaries
  1745. and sequences work well. Unmapped character ordinals (ones which cause a
  1746. LookupError) are left untouched and are copied as-is.
  1747. This function used an int type for size. This might require
  1748. changes in your code for properly supporting 64-bit systems."""
  1749. raise NotImplementedError
  1750. @cpython_api([rffi.CCHARP, rffi.INT_real, rffi.CCHARP, rffi.INTP], PyObject)
  1751. def PyUnicode_DecodeMBCSStateful(space, s, size, errors, consumed):
  1752. """If consumed is NULL, behave like PyUnicode_DecodeMBCS(). If
  1753. consumed is not NULL, PyUnicode_DecodeMBCSStateful() will not decode
  1754. trailing lead byte and the number of bytes that have been decoded will be stored
  1755. in consumed.
  1756. """
  1757. raise NotImplementedError
  1758. @cpython_api([PyObject, PyObject], PyObject)
  1759. def PyUnicode_Concat(space, left, right):
  1760. """Concat two strings giving a new Unicode string."""
  1761. raise NotImplementedError
  1762. @cpython_api([PyObject, PyObject, rffi.CCHARP], PyObject)
  1763. def PyUnicode_Translate(space, str, table, errors):
  1764. """Translate a string by applying a character mapping table to it and return the
  1765. resulting Unicode object.
  1766. The mapping table must map Unicode ordinal integers to Unicode ordinal integers
  1767. or None (causing deletion of the character).
  1768. Mapping tables need only provide the __getitem__() interface; dictionaries
  1769. and sequences work well. Unmapped character ordinals (ones which cause a
  1770. LookupError) are left untouched and are copied as-is.
  1771. errors has the usual meaning for codecs. It may be NULL which indicates to
  1772. use the default error handling."""
  1773. raise NotImplementedError
  1774. @cpython_api([PyObject, PyObject, rffi.INT_real], PyObject)
  1775. def PyUnicode_RichCompare(space, left, right, op):
  1776. """Rich compare two unicode strings and return one of the following:
  1777. NULL in case an exception was raised
  1778. Py_True or Py_False for successful comparisons
  1779. Py_NotImplemented in case the type combination is unknown
  1780. Note that Py_EQ and Py_NE comparisons can cause a
  1781. UnicodeWarning in case the conversion of the arguments to Unicode fails
  1782. with a UnicodeDecodeError.
  1783. Possible values for op are Py_GT, Py_GE, Py_EQ,
  1784. Py_NE, Py_LT, and Py_LE."""
  1785. raise NotImplementedError
  1786. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  1787. def PyUnicode_Contains(space, container, element):
  1788. """Check whether element is contained in container and return true or false
  1789. accordingly.
  1790. element has to coerce to a one element Unicode string. -1 is returned if
  1791. there was an error."""
  1792. raise NotImplementedError
  1793. @cpython_api([rffi.INT_real, rffi.CCHARPP], rffi.INT_real, error=2)
  1794. def Py_Main(space, argc, argv):
  1795. """The main program for the standard interpreter. This is made available for
  1796. programs which embed Python. The argc and argv parameters should be
  1797. prepared exactly as those which are passed to a C program's main()
  1798. function. It is important to note that the argument list may be modified (but
  1799. the contents of the strings pointed to by the argument list are not). The return
  1800. value will be the integer passed to the sys.exit() function, 1 if the
  1801. interpreter exits due to an exception, or 2 if the parameter list does not
  1802. represent a valid Python command line.
  1803. Note that if an otherwise unhandled SystemError is raised, this
  1804. function will not return 1, but exit the process, as long as
  1805. Py_InspectFlag is not set."""
  1806. raise NotImplementedError
  1807. @cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1)
  1808. def PyRun_AnyFile(space, fp, filename):
  1809. """This is a simplified interface to PyRun_AnyFileExFlags() below, leaving
  1810. closeit set to 0 and flags set to NULL."""
  1811. raise NotImplementedError
  1812. @cpython_api([FILE, rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1)
  1813. def PyRun_AnyFileFlags(space, fp, filename, flags):
  1814. """This is a simplified interface to PyRun_AnyFileExFlags() below, leaving
  1815. the closeit argument set to 0."""
  1816. raise NotImplementedError
  1817. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real], rffi.INT_real, error=-1)
  1818. def PyRun_AnyFileEx(space, fp, filename, closeit):
  1819. """This is a simplified interface to PyRun_AnyFileExFlags() below, leaving
  1820. the flags argument set to NULL."""
  1821. raise NotImplementedError
  1822. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyCompilerFlags], rffi.INT_real, error=-1)
  1823. def PyRun_AnyFileExFlags(space, fp, filename, closeit, flags):
  1824. """If fp refers to a file associated with an interactive device (console or
  1825. terminal input or Unix pseudo-terminal), return the value of
  1826. PyRun_InteractiveLoop(), otherwise return the result of
  1827. PyRun_SimpleFile(). If filename is NULL, this function uses
  1828. "???" as the filename."""
  1829. raise NotImplementedError
  1830. @cpython_api([rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1)
  1831. def PyRun_SimpleStringFlags(space, command, flags):
  1832. """Executes the Python source code from command in the __main__ module
  1833. according to the flags argument. If __main__ does not already exist, it
  1834. is created. Returns 0 on success or -1 if an exception was raised. If
  1835. there was an error, there is no way to get the exception information. For the
  1836. meaning of flags, see below.
  1837. Note that if an otherwise unhandled SystemError is raised, this
  1838. function will not return -1, but exit the process, as long as
  1839. Py_InspectFlag is not set."""
  1840. raise NotImplementedError
  1841. @cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1)
  1842. def PyRun_SimpleFile(space, fp, filename):
  1843. """This is a simplified interface to PyRun_SimpleFileExFlags() below,
  1844. leaving closeit set to 0 and flags set to NULL."""
  1845. raise NotImplementedError
  1846. @cpython_api([FILE, rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1)
  1847. def PyRun_SimpleFileFlags(space, fp, filename, flags):
  1848. """This is a simplified interface to PyRun_SimpleFileExFlags() below,
  1849. leaving closeit set to 0."""
  1850. raise NotImplementedError
  1851. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real], rffi.INT_real, error=-1)
  1852. def PyRun_SimpleFileEx(space, fp, filename, closeit):
  1853. """This is a simplified interface to PyRun_SimpleFileExFlags() below,
  1854. leaving flags set to NULL."""
  1855. raise NotImplementedError
  1856. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyCompilerFlags], rffi.INT_real, error=-1)
  1857. def PyRun_SimpleFileExFlags(space, fp, filename, closeit, flags):
  1858. """Similar to PyRun_SimpleStringFlags(), but the Python source code is read
  1859. from fp instead of an in-memory string. filename should be the name of the
  1860. file. If closeit is true, the file is closed before PyRun_SimpleFileExFlags
  1861. returns."""
  1862. raise NotImplementedError
  1863. @cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1)
  1864. def PyRun_InteractiveOne(space, fp, filename):
  1865. """This is a simplified interface to PyRun_InteractiveOneFlags() below,
  1866. leaving flags set to NULL."""
  1867. raise NotImplementedError
  1868. @cpython_api([FILE, rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1)
  1869. def PyRun_InteractiveOneFlags(space, fp, filename, flags):
  1870. """Read and execute a single statement from a file associated with an
  1871. interactive device according to the flags argument. The user will be
  1872. prompted using sys.ps1 and sys.ps2. Returns 0 when the input was
  1873. executed successfully, -1 if there was an exception, or an error code
  1874. from the errcode.h include file distributed as part of Python if
  1875. there was a parse error. (Note that errcode.h is not included by
  1876. Python.h, so must be included specifically if needed.)"""
  1877. raise NotImplementedError
  1878. @cpython_api([FILE, rffi.CCHARP], rffi.INT_real, error=-1)
  1879. def PyRun_InteractiveLoop(space, fp, filename):
  1880. """This is a simplified interface to PyRun_InteractiveLoopFlags() below,
  1881. leaving flags set to NULL."""
  1882. raise NotImplementedError
  1883. @cpython_api([FILE, rffi.CCHARP, PyCompilerFlags], rffi.INT_real, error=-1)
  1884. def PyRun_InteractiveLoopFlags(space, fp, filename, flags):
  1885. """Read and execute statements from a file associated with an interactive device
  1886. until EOF is reached. The user will be prompted using sys.ps1 and
  1887. sys.ps2. Returns 0 at EOF."""
  1888. raise NotImplementedError
  1889. @cpython_api([rffi.CCHARP, rffi.INT_real], _node)
  1890. def PyParser_SimpleParseString(space, str, start):
  1891. """This is a simplified interface to
  1892. PyParser_SimpleParseStringFlagsFilename() below, leaving filename set
  1893. to NULL and flags set to 0."""
  1894. raise NotImplementedError
  1895. @cpython_api([rffi.CCHARP, rffi.INT_real, rffi.INT_real], _node)
  1896. def PyParser_SimpleParseStringFlags(space, str, start, flags):
  1897. """This is a simplified interface to
  1898. PyParser_SimpleParseStringFlagsFilename() below, leaving filename set
  1899. to NULL."""
  1900. raise NotImplementedError
  1901. @cpython_api([rffi.CCHARP, rffi.CCHARP, rffi.INT_real, rffi.INT_real], _node)
  1902. def PyParser_SimpleParseStringFlagsFilename(space, str, filename, start, flags):
  1903. """Parse Python source code from str using the start token start according to
  1904. the flags argument. The result can be used to create a code object which can
  1905. be evaluated efficiently. This is useful if a code fragment must be evaluated
  1906. many times."""
  1907. raise NotImplementedError
  1908. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real], _node)
  1909. def PyParser_SimpleParseFile(space, fp, filename, start):
  1910. """This is a simplified interface to PyParser_SimpleParseFileFlags() below,
  1911. leaving flags set to 0"""
  1912. raise NotImplementedError
  1913. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real, rffi.INT_real], _node)
  1914. def PyParser_SimpleParseFileFlags(space, fp, filename, start, flags):
  1915. """Similar to PyParser_SimpleParseStringFlagsFilename(), but the Python
  1916. source code is read from fp instead of an in-memory string."""
  1917. raise NotImplementedError
  1918. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyObject, PyObject, rffi.INT_real], PyObject)
  1919. def PyRun_FileEx(space, fp, filename, start, globals, locals, closeit):
  1920. """This is a simplified interface to PyRun_FileExFlags() below, leaving
  1921. flags set to NULL."""
  1922. raise NotImplementedError
  1923. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyObject, PyObject, PyCompilerFlags], PyObject)
  1924. def PyRun_FileFlags(space, fp, filename, start, globals, locals, flags):
  1925. """This is a simplified interface to PyRun_FileExFlags() below, leaving
  1926. closeit set to 0."""
  1927. raise NotImplementedError
  1928. @cpython_api([FILE, rffi.CCHARP, rffi.INT_real, PyObject, PyObject, rffi.INT_real, PyCompilerFlags], PyObject)
  1929. def PyRun_FileExFlags(space, fp, filename, start, globals, locals, closeit, flags):
  1930. """Similar to PyRun_StringFlags(), but the Python source code is read from
  1931. fp instead of an in-memory string. filename should be the name of the file.
  1932. If closeit is true, the file is closed before PyRun_FileExFlags()
  1933. returns."""
  1934. raise NotImplementedError
  1935. @cpython_api([PyCodeObject, PyObject, PyObject, PyObjectP, rffi.INT_real, PyObjectP, rffi.INT_real, PyObjectP, rffi.INT_real, PyObject], PyObject)
  1936. def PyEval_EvalCodeEx(space, co, globals, locals, args, argcount, kws, kwcount, defs, defcount, closure):
  1937. """Evaluate a precompiled code object, given a particular environment for its
  1938. evaluation. This environment consists of dictionaries of global and local
  1939. variables, arrays of arguments, keywords and defaults, and a closure tuple of
  1940. cells."""
  1941. raise NotImplementedError
  1942. @cpython_api([PyFrameObject], PyObject)
  1943. def PyEval_EvalFrame(space, f):
  1944. """Evaluate an execution frame. This is a simplified interface to
  1945. PyEval_EvalFrameEx, for backward compatibility."""
  1946. raise NotImplementedError
  1947. @cpython_api([PyFrameObject, rffi.INT_real], PyObject)
  1948. def PyEval_EvalFrameEx(space, f, throwflag):
  1949. """This is the main, unvarnished function of Python interpretation. It is
  1950. literally 2000 lines long. The code object associated with the execution
  1951. frame f is executed, interpreting bytecode and executing calls as needed.
  1952. The additional throwflag parameter can mostly be ignored - if true, then
  1953. it causes an exception to immediately be thrown; this is used for the
  1954. throw() methods of generator objects."""
  1955. raise NotImplementedError
  1956. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1957. def PyWeakref_Check(space, ob):
  1958. """Return true if ob is either a reference or proxy object.
  1959. """
  1960. raise NotImplementedError
  1961. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1962. def PyWeakref_CheckRef(space, ob):
  1963. """Return true if ob is a reference object.
  1964. """
  1965. raise NotImplementedError
  1966. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  1967. def PyWeakref_CheckProxy(space, ob):
  1968. """Return true if ob is a proxy object.
  1969. """
  1970. raise NotImplementedError