PageRenderTime 61ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/pypy/module/cpyext/stubs.py

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