PageRenderTime 71ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/pypy/module/cpyext/stubs.py

https://bitbucket.org/nbtaylor/pypy
Python | 2426 lines | 2417 code | 5 blank | 4 comment | 1 complexity | 7cc0743d74edcec448665c84173718ca 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([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. en

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