PageRenderTime 99ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/pypy/module/cpyext/stubs.py

https://bitbucket.org/chence/pypy
Python | 2430 lines | 2421 code | 5 blank | 4 comment | 1 complexity | 33da3fdae404e6c46f67ac6e98cb49dd MD5 | raw file

Large files files are truncated, but you can click here to view the full 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([PyTypeObjectPtr, PyMethodDef], PyObject)
  359. def PyDescr_NewClassMethod(space, type, method):
  360. raise NotImplementedError
  361. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  362. def PyDescr_IsData(space, descr):
  363. """Return true if the descriptor objects descr describes a data attribute, or
  364. false if it describes a method. descr must be a descriptor object; there is
  365. no error checking.
  366. """
  367. raise NotImplementedError
  368. @cpython_api([PyObject, PyObject], PyObject)
  369. def PyWrapper_New(space, w_d, w_self):
  370. raise NotImplementedError
  371. @cpython_api([PyObject, PyObject, rffi.INT_real], rffi.INT_real, error=-1)
  372. def PyDict_Merge(space, a, b, override):
  373. """Iterate over mapping object b adding key-value pairs to dictionary a.
  374. b may be a dictionary, or any object supporting PyMapping_Keys()
  375. and PyObject_GetItem(). If override is true, existing pairs in a
  376. will be replaced if a matching key is found in b, otherwise pairs will
  377. only be added if there is not a matching key in a. Return 0 on
  378. success or -1 if an exception was raised.
  379. """
  380. raise NotImplementedError
  381. @cpython_api([PyObject, PyObject, rffi.INT_real], rffi.INT_real, error=-1)
  382. def PyDict_MergeFromSeq2(space, a, seq2, override):
  383. """Update or merge into dictionary a, from the key-value pairs in seq2.
  384. seq2 must be an iterable object producing iterable objects of length 2,
  385. viewed as key-value pairs. In case of duplicate keys, the last wins if
  386. override is true, else the first wins. Return 0 on success or -1
  387. if an exception was raised. Equivalent Python (except for the return
  388. value):
  389. def PyDict_MergeFromSeq2(a, seq2, override):
  390. for key, value in seq2:
  391. if override or key not in a:
  392. a[key] = value
  393. """
  394. raise NotImplementedError
  395. @cpython_api([rffi.INT_real], PyObject)
  396. def PyErr_SetFromWindowsErr(space, ierr):
  397. """This is a convenience function to raise WindowsError. If called with
  398. ierr of 0, the error code returned by a call to GetLastError()
  399. is used instead. It calls the Win32 function FormatMessage() to retrieve
  400. the Windows description of error code given by ierr or GetLastError(),
  401. then it constructs a tuple object whose first item is the ierr value and whose
  402. second item is the corresponding error message (gotten from
  403. FormatMessage()), and then calls PyErr_SetObject(PyExc_WindowsError,
  404. object). This function always returns NULL. Availability: Windows.
  405. Return value: always NULL."""
  406. raise NotImplementedError
  407. @cpython_api([PyObject, rffi.INT_real], PyObject)
  408. def PyErr_SetExcFromWindowsErr(space, type, ierr):
  409. """Similar to PyErr_SetFromWindowsErr(), with an additional parameter
  410. specifying the exception type to be raised. Availability: Windows.
  411. Return value: always NULL."""
  412. raise NotImplementedError
  413. @cpython_api([rffi.INT_real, rffi.CCHARP], PyObject)
  414. def PyErr_SetFromWindowsErrWithFilename(space, ierr, filename):
  415. """Similar to PyErr_SetFromWindowsErr(), with the additional behavior that
  416. if filename is not NULL, it is passed to the constructor of
  417. WindowsError as a third parameter. Availability: Windows.
  418. Return value: always NULL."""
  419. raise NotImplementedError
  420. @cpython_api([PyObject, rffi.INT_real, rffi.CCHARP], PyObject)
  421. def PyErr_SetExcFromWindowsErrWithFilename(space, type, ierr, filename):
  422. """Similar to PyErr_SetFromWindowsErrWithFilename(), with an additional
  423. parameter specifying the exception type to be raised. Availability: Windows.
  424. Return value: always NULL."""
  425. raise NotImplementedError
  426. @cpython_api([PyObject, rffi.CCHARP, rffi.CCHARP, rffi.INT_real, rffi.CCHARP, PyObject], rffi.INT_real, error=-1)
  427. def PyErr_WarnExplicit(space, category, message, filename, lineno, module, registry):
  428. """Issue a warning message with explicit control over all warning attributes. This
  429. is a straightforward wrapper around the Python function
  430. warnings.warn_explicit(), see there for more information. The module
  431. and registry arguments may be set to NULL to get the default effect
  432. described there."""
  433. raise NotImplementedError
  434. @cpython_api([rffi.INT_real], rffi.INT_real, error=CANNOT_FAIL)
  435. def PySignal_SetWakeupFd(space, fd):
  436. """This utility function specifies a file descriptor to which a '\0' byte will
  437. be written whenever a signal is received. It returns the previous such file
  438. descriptor. The value -1 disables the feature; this is the initial state.
  439. This is equivalent to signal.set_wakeup_fd() in Python, but without any
  440. error checking. fd should be a valid file descriptor. The function should
  441. only be called from the main thread."""
  442. raise NotImplementedError
  443. @cpython_api([rffi.CCHARP, rffi.CCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  444. def PyUnicodeDecodeError_Create(space, encoding, object, length, start, end, reason):
  445. """Create a UnicodeDecodeError object with the attributes encoding,
  446. object, length, start, end and reason."""
  447. raise NotImplementedError
  448. @cpython_api([rffi.CCHARP, rffi.CWCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  449. def PyUnicodeEncodeError_Create(space, encoding, object, length, start, end, reason):
  450. """Create a UnicodeEncodeError object with the attributes encoding,
  451. object, length, start, end and reason."""
  452. raise NotImplementedError
  453. @cpython_api([rffi.CWCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  454. def PyUnicodeTranslateError_Create(space, object, length, start, end, reason):
  455. """Create a UnicodeTranslateError object with the attributes object,
  456. length, start, end and reason."""
  457. raise NotImplementedError
  458. @cpython_api([PyObject], PyObject)
  459. def PyUnicodeDecodeError_GetEncoding(space, exc):
  460. """Return the encoding attribute of the given exception object."""
  461. raise NotImplementedError
  462. @cpython_api([PyObject], PyObject)
  463. def PyUnicodeDecodeError_GetObject(space, exc):
  464. """Return the object attribute of the given exception object."""
  465. raise NotImplementedError
  466. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  467. def PyUnicodeDecodeError_GetStart(space, exc, start):
  468. """Get the start attribute of the given exception object and place it into
  469. *start. start must not be NULL. Return 0 on success, -1 on
  470. failure."""
  471. raise NotImplementedError
  472. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  473. def PyUnicodeDecodeError_SetStart(space, exc, start):
  474. """Set the start attribute of the given exception object to start. Return
  475. 0 on success, -1 on failure."""
  476. raise NotImplementedError
  477. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  478. def PyUnicodeDecodeError_GetEnd(space, exc, end):
  479. """Get the end attribute of the given exception object and place it into
  480. *end. end must not be NULL. Return 0 on success, -1 on
  481. failure."""
  482. raise NotImplementedError
  483. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  484. def PyUnicodeDecodeError_SetEnd(space, exc, end):
  485. """Set the end attribute of the given exception object to end. Return 0
  486. on success, -1 on failure."""
  487. raise NotImplementedError
  488. @cpython_api([PyObject], PyObject)
  489. def PyUnicodeDecodeError_GetReason(space, exc):
  490. """Return the reason attribute of the given exception object."""
  491. raise NotImplementedError
  492. @cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1)
  493. def PyUnicodeDecodeError_SetReason(space, exc, reason):
  494. """Set the reason attribute of the given exception object to reason. Return
  495. 0 on success, -1 on failure."""
  496. raise NotImplementedError
  497. @cpython_api([rffi.CCHARP], rffi.INT_real, error=1)
  498. def Py_EnterRecursiveCall(space, where):
  499. """Marks a point where a recursive C-level call is about to be performed.
  500. If USE_STACKCHECK is defined, this function checks if the the OS
  501. stack overflowed using PyOS_CheckStack(). In this is the case, it
  502. sets a MemoryError and returns a nonzero value.
  503. The function then checks if the recursion limit is reached. If this is the
  504. case, a RuntimeError is set and a nonzero value is returned.
  505. Otherwise, zero is returned.
  506. where should be a string such as " in instance check" to be
  507. concatenated to the RuntimeError message caused by the recursion depth
  508. limit."""
  509. raise NotImplementedError
  510. @cpython_api([], lltype.Void)
  511. def Py_LeaveRecursiveCall(space):
  512. """Ends a Py_EnterRecursiveCall(). Must be called once for each
  513. successful invocation of Py_EnterRecursiveCall()."""
  514. raise NotImplementedError
  515. @cpython_api([PyFileObject], lltype.Void)
  516. def PyFile_IncUseCount(space, p):
  517. """Increments the PyFileObject's internal use count to indicate
  518. that the underlying FILE* is being used.
  519. This prevents Python from calling f_close() on it from another thread.
  520. Callers of this must call PyFile_DecUseCount() when they are
  521. finished with the FILE*. Otherwise the file object will
  522. never be closed by Python.
  523. The GIL must be held while calling this function.
  524. The suggested use is to call this after PyFile_AsFile() and before
  525. you release the GIL:
  526. FILE *fp = PyFile_AsFile(p);
  527. PyFile_IncUseCount(p);
  528. /* ... */
  529. Py_BEGIN_ALLOW_THREADS
  530. do_something(fp);
  531. Py_END_ALLOW_THREADS
  532. /* ... */
  533. PyFile_DecUseCount(p);
  534. """
  535. raise NotImplementedError
  536. @cpython_api([PyFileObject], lltype.Void)
  537. def PyFile_DecUseCount(space, p):
  538. """Decrements the PyFileObject's internal unlocked_count member to
  539. indicate that the caller is done with its own use of the FILE*.
  540. This may only be called to undo a prior call to PyFile_IncUseCount().
  541. The GIL must be held while calling this function (see the example
  542. above).
  543. """
  544. raise NotImplementedError
  545. @cpython_api([PyFileObject, rffi.CCHARP], rffi.INT_real, error=0)
  546. def PyFile_SetEncoding(space, p, enc):
  547. """Set the file's encoding for Unicode output to enc. Return 1 on success and 0
  548. on failure.
  549. """
  550. raise NotImplementedError
  551. @cpython_api([PyFileObject, rffi.CCHARP, rffi.CCHARP], rffi.INT_real, error=0)
  552. def PyFile_SetEncodingAndErrors(space, p, enc, errors):
  553. """Set the file's encoding for Unicode output to enc, and its error
  554. mode to err. Return 1 on success and 0 on failure.
  555. """
  556. raise NotImplementedError
  557. @cpython_api([], PyObject)
  558. def PyFloat_GetInfo(space):
  559. """Return a structseq instance which contains information about the
  560. precision, minimum and maximum values of a float. It's a thin wrapper
  561. around the header file float.h.
  562. """
  563. raise NotImplementedError
  564. @cpython_api([], rffi.DOUBLE, error=CANNOT_FAIL)
  565. def PyFloat_GetMax(space):
  566. """Return the maximum representable finite float DBL_MAX as C double.
  567. """
  568. raise NotImplementedError
  569. @cpython_api([], rffi.DOUBLE, error=CANNOT_FAIL)
  570. def PyFloat_GetMin(space):
  571. """Return the minimum normalized positive float DBL_MIN as C double.
  572. """
  573. raise NotImplementedError
  574. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  575. def PyFloat_ClearFreeList(space):
  576. """Clear the float free list. Return the number of items that could not
  577. be freed.
  578. """
  579. raise NotImplementedError
  580. @cpython_api([rffi.CCHARP, PyFloatObject], lltype.Void)
  581. def PyFloat_AsString(space, buf, v):
  582. """Convert the argument v to a string, using the same rules as
  583. str(). The length of buf should be at least 100.
  584. This function is unsafe to call because it writes to a buffer whose
  585. length it does not know.
  586. Use PyObject_Str() or PyOS_double_to_string() instead."""
  587. raise NotImplementedError
  588. @cpython_api([rffi.CCHARP, PyFloatObject], lltype.Void)
  589. def PyFloat_AsReprString(space, buf, v):
  590. """Same as PyFloat_AsString, except uses the same rules as
  591. repr(). The length of buf should be at least 100.
  592. This function is unsafe to call because it writes to a buffer whose
  593. length it does not know.
  594. Use PyObject_Repr() or PyOS_double_to_string() instead."""
  595. raise NotImplementedError
  596. @cpython_api([PyObject, PyObject], PyObject)
  597. def PyFunction_New(space, code, globals):
  598. """Return a new function object associated with the code object code. globals
  599. must be a dictionary with the global variables accessible to the function.
  600. The function's docstring, name and __module__ are retrieved from the code
  601. object, the argument defaults and closure are set to NULL."""
  602. raise NotImplementedError
  603. @cpython_api([PyObject], PyObject)
  604. def PyFunction_GetGlobals(space, op):
  605. """Return the globals dictionary associated with the function object op."""
  606. borrow_from()
  607. raise NotImplementedError
  608. @cpython_api([PyObject], PyObject)
  609. def PyFunction_GetModule(space, op):
  610. """Return the __module__ attribute of the function object op. This is normally
  611. a string containing the module name, but can be set to any other object by
  612. Python code."""
  613. borrow_from()
  614. raise NotImplementedError
  615. @cpython_api([PyObject], PyObject)
  616. def PyFunction_GetDefaults(space, op):
  617. """Return the argument default values of the function object op. This can be a
  618. tuple of arguments or NULL."""
  619. borrow_from()
  620. raise NotImplementedError
  621. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  622. def PyFunction_SetDefaults(space, op, defaults):
  623. """Set the argument default values for the function object op. defaults must be
  624. Py_None or a tuple.
  625. Raises SystemError and returns -1 on failure."""
  626. raise NotImplementedError
  627. @cpython_api([PyObject], PyObject)
  628. def PyFunction_GetClosure(space, op):
  629. """Return the closure associated with the function object op. This can be NULL
  630. or a tuple of cell objects."""
  631. borrow_from()
  632. raise NotImplementedError
  633. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  634. def PyFunction_SetClosure(space, op, closure):
  635. """Set the closure associated with the function object op. closure must be
  636. Py_None or a tuple of cell objects.
  637. Raises SystemError and returns -1 on failure."""
  638. raise NotImplementedError
  639. @cpython_api([PyTypeObjectPtr, Py_ssize_t], PyObject)
  640. def PyObject_GC_NewVar(space, type, size):
  641. """Analogous to PyObject_NewVar() but for container objects with the
  642. Py_TPFLAGS_HAVE_GC flag set.
  643. This function used an int type for size. This might require
  644. changes in your code for properly supporting 64-bit systems."""
  645. raise NotImplementedError
  646. @cpython_api([PyObject, Py_ssize_t], PyObject)
  647. def PyObject_GC_Resize(space, op, newsize):
  648. """Resize an object allocated by PyObject_NewVar(). Returns the
  649. resized object or NULL on failure.
  650. This function used an int type for newsize. This might
  651. require changes in your code for properly supporting 64-bit systems."""
  652. raise NotImplementedError
  653. @cpython_api([PyObject], lltype.Void)
  654. def _PyObject_GC_TRACK(space, op):
  655. """A macro version of PyObject_GC_Track(). It should not be used for
  656. extension modules."""
  657. raise NotImplementedError
  658. @cpython_api([PyObject], lltype.Void)
  659. def _PyObject_GC_UNTRACK(space, op):
  660. """A macro version of PyObject_GC_UnTrack(). It should not be used for
  661. extension modules."""
  662. raise NotImplementedError
  663. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  664. def PyGen_Check(space, ob):
  665. """Return true if ob is a generator object; ob must not be NULL."""
  666. raise NotImplementedError
  667. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  668. def PyGen_CheckExact(space, ob):
  669. """Return true if ob's type is PyGen_Type is a generator object; ob must not
  670. be NULL."""
  671. raise NotImplementedError
  672. @cpython_api([PyFrameObject], PyObject)
  673. def PyGen_New(space, frame):
  674. """Create and return a new generator object based on the frame object. A
  675. reference to frame is stolen by this function. The parameter must not be
  676. NULL."""
  677. raise NotImplementedError
  678. @cpython_api([rffi.CCHARP, PyObject, PyObject, PyObject], PyObject)
  679. def PyImport_ImportModuleEx(space, name, globals, locals, fromlist):
  680. """Import a module. This is best described by referring to the built-in
  681. Python function __import__(), as the standard __import__() function calls
  682. this function directly.
  683. The return value is a new reference to the imported module or top-level package,
  684. or NULL with an exception set on failure (before Python 2.4, the module may
  685. still be created in this case). Like for __import__(), the return value
  686. when a submodule of a package was requested is normally the top-level package,
  687. unless a non-empty fromlist was given.
  688. Failing imports remove incomplete module objects.
  689. The function is an alias for PyImport_ImportModuleLevel() with
  690. -1 as level, meaning relative import."""
  691. raise NotImplementedError
  692. @cpython_api([rffi.CCHARP, PyObject, PyObject, PyObject, rffi.INT_real], PyObject)
  693. def PyImport_ImportModuleLevel(space, name, globals, locals, fromlist, level):
  694. """Import a module. This is best described by referring to the built-in Python
  695. function __import__(), as the standard __import__() function calls
  696. this function directly.
  697. The return value is a new reference to the imported module or top-level package,
  698. or NULL with an exception set on failure. Like for __import__(),
  699. the return value when a submodule of a package was requested is normally the
  700. top-level package, unless a non-empty fromlist was given.
  701. """
  702. raise NotImplementedError
  703. @cpython_api([], lltype.Signed, error=CANNOT_FAIL)
  704. def PyImport_GetMagicNumber(space):
  705. """Return the magic number for Python bytecode files (a.k.a. .pyc and
  706. .pyo files). The magic number should be present in the first four bytes
  707. of the bytecode file, in little-endian byte order."""
  708. raise NotImplementedError
  709. @cpython_api([PyObject], PyObject)
  710. def PyImport_GetImporter(space, path):
  711. """Return an importer object for a sys.path/pkg.__path__ item
  712. path, possibly by fetching it from the sys.path_importer_cache
  713. dict. If it wasn't yet cached, traverse sys.path_hooks until a hook
  714. is found that can handle the path item. Return None if no hook could;
  715. this tells our caller it should fall back to the built-in import mechanism.
  716. Cache the result in sys.path_importer_cache. Return a new reference
  717. to the importer object.
  718. """
  719. raise NotImplementedError
  720. @cpython_api([], lltype.Void)
  721. def _PyImport_Init(space):
  722. """Initialize the import mechanism. For internal use only."""
  723. raise NotImplementedError
  724. @cpython_api([], lltype.Void)
  725. def PyImport_Cleanup(space):
  726. """Empty the module table. For internal use only."""
  727. raise NotImplementedError
  728. @cpython_api([], lltype.Void)
  729. def _PyImport_Fini(space):
  730. """Finalize the import mechanism. For internal use only."""
  731. raise NotImplementedError
  732. @cpython_api([rffi.CCHARP, rffi.CCHARP], PyObject)
  733. def _PyImport_FindExtension(space, name, filename):
  734. """For internal use only."""
  735. raise NotImplementedError
  736. @cpython_api([rffi.CCHARP, rffi.CCHARP], PyObject)
  737. def _PyImport_FixupExtension(space, name, filename):
  738. """For internal use only."""
  739. raise NotImplementedError
  740. @cpython_api([rffi.CCHARP], rffi.INT_real, error=-1)
  741. def PyImport_ImportFrozenModule(space, name):
  742. """Load a frozen module named name. Return 1 for success, 0 if the
  743. module is not found, and -1 with an exception set if the initialization
  744. failed. To access the imported module on a successful load, use
  745. PyImport_ImportModule(). (Note the misnomer --- this function would
  746. reload the module if it was already imported.)"""
  747. raise NotImplementedError
  748. @cpython_api([rffi.CCHARP, rffi.VOIDP], rffi.INT_real, error=-1)
  749. def PyImport_AppendInittab(space, name, initfunc):
  750. """Add a single module to the existing table of built-in modules. This is a
  751. convenience wrapper around PyImport_ExtendInittab(), returning -1 if
  752. the table could not be extended. The new module can be imported by the name
  753. name, and uses the function initfunc as the initialization function called
  754. on the first attempted import. This should be called before
  755. Py_Initialize()."""
  756. raise NotImplementedError
  757. @cpython_api([_inittab], rffi.INT_real, error=-1)
  758. def PyImport_ExtendInittab(space, newtab):
  759. """Add a collection of modules to the table of built-in modules. The newtab
  760. array must end with a sentinel entry which contains NULL for the name
  761. field; failure to provide the sentinel value can result in a memory fault.
  762. Returns 0 on success or -1 if insufficient memory could be allocated to
  763. extend the internal table. In the event of failure, no modules are added to the
  764. internal table. This should be called before Py_Initialize()."""
  765. raise NotImplementedError
  766. @cpython_api([], lltype.Void)
  767. def Py_Initialize(space):
  768. """Initialize the Python interpreter. In an application embedding Python,
  769. this should be called before using any other Python/C API functions; with
  770. the exception of Py_SetProgramName(), PyEval_InitThreads(),
  771. PyEval_ReleaseLock(), and PyEval_AcquireLock(). This initializes the table
  772. of loaded modules (sys.modules), and creates the fundamental modules
  773. __builtin__, __main__ and sys. It also initializes the module search path
  774. (sys.path). It does not set sys.argv; use PySys_SetArgvEx() for that. This
  775. is a no-op when called for a second time (without calling Py_Finalize()
  776. first). There is no return value; it is a fatal error if the initialization
  777. fails."""
  778. raise NotImplementedError
  779. @cpython_api([rffi.INT_real], lltype.Void)
  780. def Py_InitializeEx(space, initsigs):
  781. """This function works like Py_Initialize() if initsigs is 1. If
  782. initsigs is 0, it skips initialization registration of signal handlers, which
  783. might be useful when Python is embedded.
  784. """
  785. raise NotImplementedError
  786. @cpython_api([], lltype.Void)
  787. def Py_Finalize(space):
  788. """Undo all initializations made by Py_Initialize() and subsequent use of
  789. Python/C API functions, and destroy all sub-interpreters (see
  790. Py_NewInterpreter() below) that were created and not yet destroyed since
  791. the last call to Py_Initialize(). Ideally, this frees all memory
  792. allocated by the Python interpreter. This is a no-op when called for a second
  793. time (without calling Py_Initialize() again first). There is no return
  794. value; errors during finalization are ignored.
  795. This function is provided for a number of reasons. An embedding application
  796. might want to restart Python without having to restart the application itself.
  797. An application that has loaded the Python interpreter from a dynamically
  798. loadable library (or DLL) might want to free all memory allocated by Python
  799. before unloading the DLL. During a hunt for memory leaks in an application a
  800. developer might want to free all memory allocated by Python before exiting from
  801. the application.
  802. Bugs and caveats: The destruction of modules and objects in modules is done
  803. in random order; this may cause destructors (__del__() methods) to fail
  804. when they depend on other objects (even functions) or modules. Dynamically
  805. loaded extension modules loaded by Python are not unloaded. Small amounts of
  806. memory allocated by the Python interpreter may not be freed (if you find a leak,
  807. please report it). Memory tied up in circular references between objects is not
  808. freed. Some memory allocated by extension modules may not be freed. Some
  809. extensions may not work properly if their initialization routine is called more
  810. than once; this can happen if an application calls Py_Initialize() and
  811. Py_Finalize() more than once."""
  812. raise NotImplementedError
  813. @cpython_api([rffi.CCHARP], lltype.Void)
  814. def Py_SetProgramName(space, name):
  815. """This function should be called before Py_Initialize() is called for the
  816. first time, if it is called at all. It tells the interpreter the value of
  817. the argv[0] argument to the main() function of the program. This is used by
  818. Py_GetPath() and some other functions below to find the Python run-time
  819. libraries relative to the interpreter executable. The default value is
  820. 'python'. The argument should point to a zero-terminated character string
  821. in static storage whose contents will not change for the duration of the
  822. program's execution. No code in the Python interpreter will change the
  823. contents of this storage."""
  824. raise NotImplementedError
  825. @cpython_api([], rffi.CCHARP)
  826. def Py_GetPrefix(space):
  827. """Return the prefix for installed platform-independent files. This is derived
  828. through a number of complicated rules from the program name set with
  829. Py_SetProgramName() and some environment variables; for example, if the
  830. program name is '/usr/local/bin/python', the prefix is '/usr/local'. The
  831. returned string points into static storage; the caller should not modify its
  832. value. This corresponds to the prefix variable in the top-level
  833. Makefile and the --prefix argument to the configure
  834. script at build time. The value is available to Python code as sys.prefix.
  835. It is only useful on Unix. See also the next function."""
  836. raise NotImplementedError
  837. @cpython_api([], rffi.CCHARP)
  838. def Py_GetExecPrefix(space):
  839. """Return the exec-prefix for installed platform-dependent files. This is
  840. derived through a number of complicated rules from the program name set with
  841. Py_SetProgramName() and some environment variables; for example, if the
  842. program name is '/usr/local/bin/python', the exec-prefix is
  843. '/usr/local'. The returned string points into static storage; the caller
  844. should not modify its value. This corresponds to the exec_prefix
  845. variable in the top-level Makefile and the --exec-prefix
  846. argument to the configure script at build time. The value is
  847. available to Python code as sys.exec_prefix. It is only useful on Unix.
  848. Background: The exec-prefix differs from the prefix when platform dependent
  849. files (such as executables and shared libraries) are installed in a different
  850. directory tree. In a typical installation, platform dependent files may be
  851. installed in the /usr/local/plat subtree while platform independent may
  852. be installed in /usr/local.
  853. Generally speaking, a platform is a combination of hardware and software
  854. families, e.g. Sparc machines running the Solaris 2.x operating system are
  855. considered the same platform, but Intel machines running Solaris 2.x are another
  856. platform, and Intel machines running Linux are yet another platform. Different
  857. major revisions of the same operating system generally also form different
  858. platforms. Non-Unix operating systems are a different story; the installation
  859. strategies on those systems are so different that the prefix and exec-prefix are
  860. meaningless, and set to the empty string. Note that compiled Python bytecode
  861. files are platform independent (but not independent from the Python version by
  862. which they were compiled!).
  863. System administrators will know how to configure the mount or
  864. automount programs to share /usr/local between platforms
  865. while having /usr/local/plat be a different filesystem for each
  866. platform."""
  867. raise NotImplementedError
  868. @cpython_api([], rffi.CCHARP)
  869. def Py_GetProgramFullPath(space):
  870. """Return the full program name of the Python executable; this is computed
  871. as a side-effect of deriving the default module search path from the program
  872. name (set by Py_SetProgramName() above). The returned string points into
  873. static storage; the caller should not modify its value. The value is
  874. available to Python code as sys.executable."""
  875. raise NotImplementedError
  876. @cpython_api([], rffi.CCHARP)
  877. def Py_GetPath(space):
  878. """Return the default module search path; this is computed from the program
  879. name (set by Py_SetProgramName() above) and some environment variables. The
  880. returned string consists of a series of directory names separated by a
  881. platform dependent delimiter character. The delimiter character is ':' on
  882. Unix and Mac OS X, ';' on Windows. The returned string points into static
  883. storage; the caller should not modify its value. The list sys.path is
  884. initialized with this value on interpreter startup; it can be (and usually
  885. is) modified later to change the search path for loading modules.
  886. XXX should give the exact rules"""
  887. raise NotImplementedError
  888. @cpython_api([], rffi.CCHARP)
  889. def Py_GetPlatform(space):
  890. """Return the platform identifier for the current platform. On Unix, this
  891. is formed from the"official" name of the operating system, converted to lower
  892. case, followed by the major revision number; e.g., for Solaris 2.x, which is
  893. also known as SunOS 5.x, the value is 'sunos5'. On Mac OS X, it is
  894. 'darwin'. On Windows, it is 'win'. The returned string points into
  895. static storage; the caller should not modify its value. The value is available
  896. to Python code as sys.platform."""
  897. raise NotImplementedError
  898. @cpython_api([], rffi.CCHARP)
  899. def Py_GetCopyright(space):
  900. """Return the official copyright string for the current Python version, for example
  901. 'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'
  902. The returned string points into static storage; the caller should not modify its
  903. value. The value is available to Python code as sys.copyright."""
  904. raise NotImplementedError
  905. @cpython_api([], rffi.CCHARP)
  906. def Py_GetCompiler(space):
  907. """Return an indication of the compiler used to build the current Python version,
  908. in square brackets, for example:
  909. "[GCC 2.7.2.2]"
  910. The returned string points into static storage; the caller should not modify its
  911. value. The value is available to Python code as part of the variable
  912. sys.version."""
  913. raise NotImplementedError
  914. @cpython_api([], rffi.CCHARP)
  915. def Py_GetBuildInfo(space):
  916. """Return information about the sequence number and build date and time of the
  917. current Python interpreter instance, for example
  918. "\#67, Aug 1 1997, 22:34:28"
  919. The returned string points into static storage; the caller should not modify its
  920. value. The value is available to Python code as part of the variable
  921. sys.version."""
  922. raise NotImplementedError
  923. @cpython_api([rffi.INT_real, rffi.CCHARPP, rffi.INT_real], lltype.Void)
  924. def PySys_SetArgvEx(space, argc, argv, updatepath):
  925. """Set sys.argv based on argc and argv. These parameters are similar to
  926. those passed to the program's main() function with the difference that the
  927. first entry should refer to the script file to be executed rather than the
  928. executable hosting the Python interpreter. If there isn't a script that
  929. will be run, the first entry in argv can be an empty string. If this
  930. function fails to initialize sys.argv, a fatal condition is signalled using
  931. Py_FatalError().
  932. If updatepath is zero, this is all the function does. If updatepath
  933. is non-zero, the function also modifies sys.path according to the
  934. following algorithm:
  935. If the name of an existing script is passed in argv[0], the absolute
  936. path of the directory where the script is located is prepended to
  937. sys.path.
  938. Otherwise (that is, if argc is 0 or argv[0] doesn't point
  939. to an existing file name), an empty string is prepended to
  940. sys.path, which is the same as prepending the current working
  941. directory (".").
  942. It is recommended that applications embedding the Python interpreter
  943. for purposes other than executing a single script pass 0 as updatepath,
  944. and update sys.path themselves if desired.
  945. See CVE-2008-5983.
  946. On versions before 2.6.6, you can achieve the same effect by manually
  947. popping the first sys.path element after having called
  948. PySys_SetArgv(), for example using:
  949. PyRun_SimpleString("import sys; sys.path.pop(0)\n");
  950. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
  951. check w/ Guido."""
  952. raise NotImplementedError
  953. @cpython_api([rffi.INT_real, rffi.CCHARPP], lltype.Void)
  954. def PySys_SetArgv(space, argc, argv):
  955. """This function works like PySys_SetArgvEx() with updatepath set to 1."""
  956. raise NotImplementedError
  957. @cpython_api([rffi.CCHARP], lltype.Void)
  958. def Py_SetPythonHome(space, home):
  959. """Set the default "home" directory, that is, the location of the standard
  960. Python libraries. See PYTHONHOME for the meaning of the
  961. argument string.
  962. The argument should point to a zero-terminated character string in static
  963. storage whose contents will not change for the duration of the program's
  964. execution. No code in the Python interpreter will change the contents of
  965. this storage."""
  966. raise NotImplementedError
  967. @cpython_api([], rffi.CCHARP)
  968. def Py_GetPythonHome(space):
  969. "…

Large files files are truncated, but you can click here to view the full file