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

/pypy/module/cpyext/stubs.py

https://bitbucket.org/jonathanslenders/pypy
Python | 2420 lines | 2411 code | 5 blank | 4 comment | 1 complexity | 0bccf61c079b150c0d59a52623d707f8 MD5 | raw file

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 rpython.rtyper.lltypesystem import rffi, lltype
  6. # we don't really care
  7. PyTypeObjectPtr = rffi.VOIDP
  8. Py_ssize_t = rffi.SSIZE_T
  9. PyMethodDef = rffi.VOIDP
  10. PyGetSetDef = rffi.VOIDP
  11. PyMemberDef = rffi.VOIDP
  12. Py_buffer = rffi.VOIDP
  13. va_list = rffi.VOIDP
  14. PyDateTime_Date = rffi.VOIDP
  15. PyDateTime_DateTime = rffi.VOIDP
  16. PyDateTime_Time = rffi.VOIDP
  17. wrapperbase = rffi.VOIDP
  18. FILE = rffi.VOIDP
  19. PyFileObject = rffi.VOIDP
  20. PyCodeObject = rffi.VOIDP
  21. PyFrameObject = rffi.VOIDP
  22. PyFloatObject = rffi.VOIDP
  23. _inittab = rffi.VOIDP
  24. PyThreadState = rffi.VOIDP
  25. PyInterpreterState = rffi.VOIDP
  26. Py_UNICODE = lltype.UniChar
  27. PyCompilerFlags = rffi.VOIDP
  28. _node = rffi.VOIDP
  29. Py_tracefunc = rffi.VOIDP
  30. @cpython_api([PyObject], lltype.Void)
  31. def _PyObject_Del(space, op):
  32. raise NotImplementedError
  33. @cpython_api([rffi.CCHARP], Py_ssize_t, error=CANNOT_FAIL)
  34. def PyBuffer_SizeFromFormat(space, format):
  35. """Return the implied ~Py_buffer.itemsize from the struct-stype
  36. ~Py_buffer.format."""
  37. raise NotImplementedError
  38. @cpython_api([rffi.INT_real, Py_ssize_t, Py_ssize_t, Py_ssize_t, lltype.Char], lltype.Void)
  39. def PyBuffer_FillContiguousStrides(space, ndim, shape, strides, itemsize, fortran):
  40. """Fill the strides array with byte-strides of a contiguous (C-style if
  41. fortran is 'C' or Fortran-style if fortran is 'F' array of the
  42. given shape with the given number of bytes per element."""
  43. raise NotImplementedError
  44. @cpython_api([Py_buffer], PyObject)
  45. def PyMemoryView_FromBuffer(space, view):
  46. """Create a memoryview object wrapping the given buffer-info structure view.
  47. The memoryview object then owns the buffer, which means you shouldn't
  48. try to release it yourself: it will be released on deallocation of the
  49. memoryview object."""
  50. raise NotImplementedError
  51. @cpython_api([PyObject, rffi.INT_real, lltype.Char], PyObject)
  52. def PyMemoryView_GetContiguous(space, obj, buffertype, order):
  53. """Create a memoryview object to a contiguous chunk of memory (in either
  54. 'C' or 'F'ortran order) from an object that defines the buffer
  55. interface. If memory is contiguous, the memoryview object points to the
  56. original memory. Otherwise copy is made and the memoryview points to a
  57. new bytes object."""
  58. raise NotImplementedError
  59. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  60. def PyMemoryView_Check(space, obj):
  61. """Return true if the object obj is a memoryview object. It is not
  62. currently allowed to create subclasses of memoryview."""
  63. raise NotImplementedError
  64. @cpython_api([PyObject], Py_buffer)
  65. def PyMemoryView_GET_BUFFER(space, obj):
  66. """Return a pointer to the buffer-info structure wrapped by the given
  67. object. The object must be a memoryview instance; this macro doesn't
  68. check its type, you must do it yourself or you will risk crashes."""
  69. raise NotImplementedError
  70. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  71. def PyByteArray_Check(space, o):
  72. """Return true if the object o is a bytearray object or an instance of a
  73. subtype of the bytearray type."""
  74. raise NotImplementedError
  75. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  76. def PyByteArray_CheckExact(space, o):
  77. """Return true if the object o is a bytearray object, but not an instance of a
  78. subtype of the bytearray type."""
  79. raise NotImplementedError
  80. @cpython_api([PyObject], PyObject)
  81. def PyByteArray_FromObject(space, o):
  82. """Return a new bytearray object from any object, o, that implements the
  83. buffer protocol.
  84. XXX expand about the buffer protocol, at least somewhere"""
  85. raise NotImplementedError
  86. @cpython_api([rffi.CCHARP, Py_ssize_t], PyObject)
  87. def PyByteArray_FromStringAndSize(space, string, len):
  88. """Create a new bytearray object from string and its length, len. On
  89. failure, NULL is returned."""
  90. raise NotImplementedError
  91. @cpython_api([PyObject, PyObject], PyObject)
  92. def PyByteArray_Concat(space, a, b):
  93. """Concat bytearrays a and b and return a new bytearray with the result."""
  94. raise NotImplementedError
  95. @cpython_api([PyObject], Py_ssize_t, error=-1)
  96. def PyByteArray_Size(space, bytearray):
  97. """Return the size of bytearray after checking for a NULL pointer."""
  98. raise NotImplementedError
  99. @cpython_api([PyObject], rffi.CCHARP)
  100. def PyByteArray_AsString(space, bytearray):
  101. """Return the contents of bytearray as a char array after checking for a
  102. NULL pointer."""
  103. raise NotImplementedError
  104. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  105. def PyByteArray_Resize(space, bytearray, len):
  106. """Resize the internal buffer of bytearray to len."""
  107. raise NotImplementedError
  108. @cpython_api([PyObject], rffi.CCHARP)
  109. def PyByteArray_AS_STRING(space, bytearray):
  110. """Macro version of PyByteArray_AsString()."""
  111. raise NotImplementedError
  112. @cpython_api([PyObject], Py_ssize_t, error=-1)
  113. def PyByteArray_GET_SIZE(space, bytearray):
  114. """Macro version of PyByteArray_Size()."""
  115. raise NotImplementedError
  116. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  117. def PyCell_Check(space, ob):
  118. """Return true if ob is a cell object; ob must not be NULL."""
  119. raise NotImplementedError
  120. @cpython_api([PyObject], PyObject)
  121. def PyCell_New(space, ob):
  122. """Create and return a new cell object containing the value ob. The parameter may
  123. be NULL."""
  124. raise NotImplementedError
  125. @cpython_api([PyObject], PyObject)
  126. def PyCell_Get(space, cell):
  127. """Return the contents of the cell cell."""
  128. raise NotImplementedError
  129. @cpython_api([PyObject], PyObject)
  130. def PyCell_GET(space, cell):
  131. """Return the contents of the cell cell, but without checking that cell is
  132. non-NULL and a cell object."""
  133. borrow_from()
  134. raise NotImplementedError
  135. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  136. def PyCell_Set(space, cell, value):
  137. """Set the contents of the cell object cell to value. This releases the
  138. reference to any current content of the cell. value may be NULL. cell
  139. must be non-NULL; if it is not a cell object, -1 will be returned. On
  140. success, 0 will be returned."""
  141. raise NotImplementedError
  142. @cpython_api([PyObject, PyObject], lltype.Void)
  143. def PyCell_SET(space, cell, value):
  144. """Sets the value of the cell object cell to value. No reference counts are
  145. adjusted, and no checks are made for safety; cell must be non-NULL and must
  146. be a cell object."""
  147. raise NotImplementedError
  148. @cpython_api([PyObject, PyObject], rffi.INT_real, error=CANNOT_FAIL)
  149. def PyClass_IsSubclass(space, klass, base):
  150. """Return true if klass is a subclass of base. Return false in all other cases."""
  151. raise NotImplementedError
  152. @cpython_api([PyObject], rffi.INT_real, error=-1)
  153. def PyCodec_Register(space, search_function):
  154. """Register a new codec search function.
  155. As side effect, this tries to load the encodings package, if not yet
  156. done, to make sure that it is always first in the list of search functions."""
  157. raise NotImplementedError
  158. @cpython_api([PyObject, rffi.CCHARP, rffi.CCHARP], PyObject)
  159. def PyCodec_Encode(space, object, encoding, errors):
  160. """Generic codec based encoding API.
  161. object is passed through the encoder function found for the given
  162. encoding using the error handling method defined by errors. errors may
  163. be NULL to use the default method defined for the codec. Raises a
  164. LookupError if no encoder can be found."""
  165. raise NotImplementedError
  166. @cpython_api([PyObject, rffi.CCHARP, rffi.CCHARP], PyObject)
  167. def PyCodec_Decode(space, object, encoding, errors):
  168. """Generic codec based decoding API.
  169. object is passed through the decoder function found for the given
  170. encoding using the error handling method defined by errors. errors may
  171. be NULL to use the default method defined for the codec. Raises a
  172. LookupError if no encoder can be found."""
  173. raise NotImplementedError
  174. @cpython_api([rffi.CCHARP], PyObject)
  175. def PyCodec_Encoder(space, encoding):
  176. """Get an encoder function for the given encoding."""
  177. raise NotImplementedError
  178. @cpython_api([rffi.CCHARP], PyObject)
  179. def PyCodec_Decoder(space, encoding):
  180. """Get a decoder function for the given encoding."""
  181. raise NotImplementedError
  182. @cpython_api([rffi.CCHARP, PyObject, rffi.CCHARP], PyObject)
  183. def PyCodec_StreamReader(space, encoding, stream, errors):
  184. """Get a StreamReader factory function for the given encoding."""
  185. raise NotImplementedError
  186. @cpython_api([rffi.CCHARP, PyObject, rffi.CCHARP], PyObject)
  187. def PyCodec_StreamWriter(space, encoding, stream, errors):
  188. """Get a StreamWriter factory function for the given encoding."""
  189. raise NotImplementedError
  190. @cpython_api([rffi.CCHARP, PyObject], rffi.INT_real, error=-1)
  191. def PyCodec_RegisterError(space, name, error):
  192. """Register the error handling callback function error under the given name.
  193. This callback function will be called by a codec when it encounters
  194. unencodable characters/undecodable bytes and name is specified as the error
  195. parameter in the call to the encode/decode function.
  196. The callback gets a single argument, an instance of
  197. UnicodeEncodeError, UnicodeDecodeError or
  198. UnicodeTranslateError that holds information about the problematic
  199. sequence of characters or bytes and their offset in the original string (see
  200. unicodeexceptions for functions to extract this information). The
  201. callback must either raise the given exception, or return a two-item tuple
  202. containing the replacement for the problematic sequence, and an integer
  203. giving the offset in the original string at which encoding/decoding should be
  204. resumed.
  205. Return 0 on success, -1 on error."""
  206. raise NotImplementedError
  207. @cpython_api([rffi.CCHARP], PyObject)
  208. def PyCodec_LookupError(space, name):
  209. """Lookup the error handling callback function registered under name. As a
  210. special case NULL can be passed, in which case the error handling callback
  211. for "strict" will be returned."""
  212. raise NotImplementedError
  213. @cpython_api([PyObject], PyObject)
  214. def PyCodec_StrictErrors(space, exc):
  215. """Raise exc as an exception."""
  216. raise NotImplementedError
  217. @cpython_api([PyObject], PyObject)
  218. def PyCodec_IgnoreErrors(space, exc):
  219. """Ignore the unicode error, skipping the faulty input."""
  220. raise NotImplementedError
  221. @cpython_api([PyObject], PyObject)
  222. def PyCodec_ReplaceErrors(space, exc):
  223. """Replace the unicode encode error with ? or U+FFFD."""
  224. raise NotImplementedError
  225. @cpython_api([PyObject], PyObject)
  226. def PyCodec_XMLCharRefReplaceErrors(space, exc):
  227. """Replace the unicode encode error with XML character references."""
  228. raise NotImplementedError
  229. @cpython_api([PyObject], PyObject)
  230. def PyCodec_BackslashReplaceErrors(space, exc):
  231. r"""Replace the unicode encode error with backslash escapes (\x, \u and
  232. \U)."""
  233. raise NotImplementedError
  234. @cpython_api([Py_complex, Py_complex], Py_complex)
  235. def _Py_c_sum(space, left, right):
  236. """Return the sum of two complex numbers, using the C Py_complex
  237. representation."""
  238. raise NotImplementedError
  239. @cpython_api([Py_complex, Py_complex], Py_complex)
  240. def _Py_c_diff(space, left, right):
  241. """Return the difference between two complex numbers, using the C
  242. Py_complex representation."""
  243. raise NotImplementedError
  244. @cpython_api([Py_complex], Py_complex)
  245. def _Py_c_neg(space, complex):
  246. """Return the negation of the complex number complex, using the C
  247. Py_complex representation."""
  248. raise NotImplementedError
  249. @cpython_api([Py_complex, Py_complex], Py_complex)
  250. def _Py_c_prod(space, left, right):
  251. """Return the product of two complex numbers, using the C Py_complex
  252. representation."""
  253. raise NotImplementedError
  254. @cpython_api([Py_complex, Py_complex], Py_complex)
  255. def _Py_c_quot(space, dividend, divisor):
  256. """Return the quotient of two complex numbers, using the C Py_complex
  257. representation."""
  258. raise NotImplementedError
  259. @cpython_api([Py_complex, Py_complex], Py_complex)
  260. def _Py_c_pow(space, num, exp):
  261. """Return the exponentiation of num by exp, using the C Py_complex
  262. representation."""
  263. raise NotImplementedError
  264. @cpython_api([Py_complex], PyObject)
  265. def PyComplex_FromCComplex(space, v):
  266. """Create a new Python complex number object from a C Py_complex value."""
  267. raise NotImplementedError
  268. @cpython_api([rffi.CCHARP, rffi.CCHARPP], rffi.DOUBLE, error=CANNOT_FAIL)
  269. def PyOS_ascii_strtod(space, nptr, endptr):
  270. """Convert a string to a double. This function behaves like the Standard C
  271. function strtod() does in the C locale. It does this without changing the
  272. current locale, since that would not be thread-safe.
  273. PyOS_ascii_strtod() should typically be used for reading configuration
  274. files or other non-user input that should be locale independent.
  275. See the Unix man page strtod(2) for details.
  276. Use PyOS_string_to_double() instead."""
  277. raise NotImplementedError
  278. @cpython_api([rffi.CCHARP, rffi.SIZE_T, rffi.CCHARP, rffi.DOUBLE], rffi.CCHARP)
  279. def PyOS_ascii_formatd(space, buffer, buf_len, format, d):
  280. """Convert a double to a string using the '.' as the decimal
  281. separator. format is a printf()-style format string specifying the
  282. number format. Allowed conversion characters are 'e', 'E', 'f',
  283. 'F', 'g' and 'G'.
  284. The return value is a pointer to buffer with the converted string or NULL if
  285. the conversion failed.
  286. This function is removed in Python 2.7 and 3.1. Use PyOS_double_to_string()
  287. instead."""
  288. raise NotImplementedError
  289. @cpython_api([rffi.DOUBLE, lltype.Char, rffi.INT_real, rffi.INT_real, rffi.INTP], rffi.CCHARP)
  290. def PyOS_double_to_string(space, val, format_code, precision, flags, ptype):
  291. """Convert a double val to a string using supplied
  292. format_code, precision, and flags.
  293. format_code must be one of 'e', 'E', 'f', 'F',
  294. 'g', 'G' or 'r'. For 'r', the supplied precision
  295. must be 0 and is ignored. The 'r' format code specifies the
  296. standard repr() format.
  297. flags can be zero or more of the values Py_DTSF_SIGN,
  298. Py_DTSF_ADD_DOT_0, or Py_DTSF_ALT, or-ed together:
  299. Py_DTSF_SIGN means to always precede the returned string with a sign
  300. character, even if val is non-negative.
  301. Py_DTSF_ADD_DOT_0 means to ensure that the returned string will not look
  302. like an integer.
  303. Py_DTSF_ALT means to apply "alternate" formatting rules. See the
  304. documentation for the PyOS_snprintf() '#' specifier for
  305. details.
  306. If ptype is non-NULL, then the value it points to will be set to one of
  307. Py_DTST_FINITE, Py_DTST_INFINITE, or Py_DTST_NAN, signifying that
  308. val is a finite number, an infinite number, or not a number, respectively.
  309. The return value is a pointer to buffer with the converted string or
  310. NULL if the conversion failed. The caller is responsible for freeing the
  311. returned string by calling PyMem_Free().
  312. """
  313. raise NotImplementedError
  314. @cpython_api([rffi.CCHARP], rffi.DOUBLE, error=CANNOT_FAIL)
  315. def PyOS_ascii_atof(space, nptr):
  316. """Convert a string to a double in a locale-independent way.
  317. See the Unix man page atof(2) for details.
  318. Use PyOS_string_to_double() instead."""
  319. raise NotImplementedError
  320. @cpython_api([rffi.CCHARP, rffi.CCHARP], rffi.CCHARP)
  321. def PyOS_stricmp(space, s1, s2):
  322. """Case insensitive comparison of strings. The function works almost
  323. identically to strcmp() except that it ignores the case.
  324. """
  325. raise NotImplementedError
  326. @cpython_api([rffi.CCHARP, rffi.CCHARP, Py_ssize_t], rffi.CCHARP)
  327. def PyOS_strnicmp(space, s1, s2, size):
  328. """Case insensitive comparison of strings. The function works almost
  329. identically to strncmp() except that it ignores the case.
  330. """
  331. raise NotImplementedError
  332. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  333. def PyTZInfo_Check(space, ob):
  334. """Return true if ob is of type PyDateTime_TZInfoType or a subtype of
  335. PyDateTime_TZInfoType. ob must not be NULL.
  336. """
  337. raise NotImplementedError
  338. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  339. def PyTZInfo_CheckExact(space, ob):
  340. """Return true if ob is of type PyDateTime_TZInfoType. ob must not be
  341. NULL.
  342. """
  343. raise NotImplementedError
  344. @cpython_api([PyTypeObjectPtr, PyGetSetDef], PyObject)
  345. def PyDescr_NewGetSet(space, type, getset):
  346. raise NotImplementedError
  347. @cpython_api([PyTypeObjectPtr, PyMemberDef], PyObject)
  348. def PyDescr_NewMember(space, type, meth):
  349. raise NotImplementedError
  350. @cpython_api([PyTypeObjectPtr, wrapperbase, rffi.VOIDP], PyObject)
  351. def PyDescr_NewWrapper(space, type, wrapper, wrapped):
  352. raise NotImplementedError
  353. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  354. def PyDescr_IsData(space, descr):
  355. """Return true if the descriptor objects descr describes a data attribute, or
  356. false if it describes a method. descr must be a descriptor object; there is
  357. no error checking.
  358. """
  359. raise NotImplementedError
  360. @cpython_api([PyObject, PyObject], PyObject)
  361. def PyWrapper_New(space, w_d, w_self):
  362. raise NotImplementedError
  363. @cpython_api([PyObject, PyObject, rffi.INT_real], rffi.INT_real, error=-1)
  364. def PyDict_Merge(space, a, b, override):
  365. """Iterate over mapping object b adding key-value pairs to dictionary a.
  366. b may be a dictionary, or any object supporting PyMapping_Keys()
  367. and PyObject_GetItem(). If override is true, existing pairs in a
  368. will be replaced if a matching key is found in b, otherwise pairs will
  369. only be added if there is not a matching key in a. Return 0 on
  370. success or -1 if an exception was raised.
  371. """
  372. raise NotImplementedError
  373. @cpython_api([PyObject, PyObject, rffi.INT_real], rffi.INT_real, error=-1)
  374. def PyDict_MergeFromSeq2(space, a, seq2, override):
  375. """Update or merge into dictionary a, from the key-value pairs in seq2.
  376. seq2 must be an iterable object producing iterable objects of length 2,
  377. viewed as key-value pairs. In case of duplicate keys, the last wins if
  378. override is true, else the first wins. Return 0 on success or -1
  379. if an exception was raised. Equivalent Python (except for the return
  380. value):
  381. def PyDict_MergeFromSeq2(a, seq2, override):
  382. for key, value in seq2:
  383. if override or key not in a:
  384. a[key] = value
  385. """
  386. raise NotImplementedError
  387. @cpython_api([rffi.INT_real], PyObject)
  388. def PyErr_SetFromWindowsErr(space, ierr):
  389. """This is a convenience function to raise WindowsError. If called with
  390. ierr of 0, the error code returned by a call to GetLastError()
  391. is used instead. It calls the Win32 function FormatMessage() to retrieve
  392. the Windows description of error code given by ierr or GetLastError(),
  393. then it constructs a tuple object whose first item is the ierr value and whose
  394. second item is the corresponding error message (gotten from
  395. FormatMessage()), and then calls PyErr_SetObject(PyExc_WindowsError,
  396. object). This function always returns NULL. Availability: Windows.
  397. Return value: always NULL."""
  398. raise NotImplementedError
  399. @cpython_api([PyObject, rffi.INT_real], PyObject)
  400. def PyErr_SetExcFromWindowsErr(space, type, ierr):
  401. """Similar to PyErr_SetFromWindowsErr(), with an additional parameter
  402. specifying the exception type to be raised. Availability: Windows.
  403. Return value: always NULL."""
  404. raise NotImplementedError
  405. @cpython_api([rffi.INT_real, rffi.CCHARP], PyObject)
  406. def PyErr_SetFromWindowsErrWithFilename(space, ierr, filename):
  407. """Similar to PyErr_SetFromWindowsErr(), with the additional behavior that
  408. if filename is not NULL, it is passed to the constructor of
  409. WindowsError as a third parameter. Availability: Windows.
  410. Return value: always NULL."""
  411. raise NotImplementedError
  412. @cpython_api([PyObject, rffi.INT_real, rffi.CCHARP], PyObject)
  413. def PyErr_SetExcFromWindowsErrWithFilename(space, type, ierr, filename):
  414. """Similar to PyErr_SetFromWindowsErrWithFilename(), with an additional
  415. parameter specifying the exception type to be raised. Availability: Windows.
  416. Return value: always NULL."""
  417. raise NotImplementedError
  418. @cpython_api([PyObject, rffi.CCHARP, rffi.CCHARP, rffi.INT_real, rffi.CCHARP, PyObject], rffi.INT_real, error=-1)
  419. def PyErr_WarnExplicit(space, category, message, filename, lineno, module, registry):
  420. """Issue a warning message with explicit control over all warning attributes. This
  421. is a straightforward wrapper around the Python function
  422. warnings.warn_explicit(), see there for more information. The module
  423. and registry arguments may be set to NULL to get the default effect
  424. described there."""
  425. raise NotImplementedError
  426. @cpython_api([rffi.INT_real], rffi.INT_real, error=CANNOT_FAIL)
  427. def PySignal_SetWakeupFd(space, fd):
  428. """This utility function specifies a file descriptor to which a '\0' byte will
  429. be written whenever a signal is received. It returns the previous such file
  430. descriptor. The value -1 disables the feature; this is the initial state.
  431. This is equivalent to signal.set_wakeup_fd() in Python, but without any
  432. error checking. fd should be a valid file descriptor. The function should
  433. only be called from the main thread."""
  434. raise NotImplementedError
  435. @cpython_api([rffi.CCHARP, rffi.CCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  436. def PyUnicodeDecodeError_Create(space, encoding, object, length, start, end, reason):
  437. """Create a UnicodeDecodeError object with the attributes encoding,
  438. object, length, start, end and reason."""
  439. raise NotImplementedError
  440. @cpython_api([rffi.CCHARP, rffi.CWCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  441. def PyUnicodeEncodeError_Create(space, encoding, object, length, start, end, reason):
  442. """Create a UnicodeEncodeError object with the attributes encoding,
  443. object, length, start, end and reason."""
  444. raise NotImplementedError
  445. @cpython_api([rffi.CWCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP], PyObject)
  446. def PyUnicodeTranslateError_Create(space, object, length, start, end, reason):
  447. """Create a UnicodeTranslateError object with the attributes object,
  448. length, start, end and reason."""
  449. raise NotImplementedError
  450. @cpython_api([PyObject], PyObject)
  451. def PyUnicodeDecodeError_GetEncoding(space, exc):
  452. """Return the encoding attribute of the given exception object."""
  453. raise NotImplementedError
  454. @cpython_api([PyObject], PyObject)
  455. def PyUnicodeDecodeError_GetObject(space, exc):
  456. """Return the object attribute of the given exception object."""
  457. raise NotImplementedError
  458. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  459. def PyUnicodeDecodeError_GetStart(space, exc, start):
  460. """Get the start attribute of the given exception object and place it into
  461. *start. start must not be NULL. Return 0 on success, -1 on
  462. failure."""
  463. raise NotImplementedError
  464. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  465. def PyUnicodeDecodeError_SetStart(space, exc, start):
  466. """Set the start attribute of the given exception object to start. Return
  467. 0 on success, -1 on failure."""
  468. raise NotImplementedError
  469. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  470. def PyUnicodeDecodeError_GetEnd(space, exc, end):
  471. """Get the end attribute of the given exception object and place it into
  472. *end. end must not be NULL. Return 0 on success, -1 on
  473. failure."""
  474. raise NotImplementedError
  475. @cpython_api([PyObject, Py_ssize_t], rffi.INT_real, error=-1)
  476. def PyUnicodeDecodeError_SetEnd(space, exc, end):
  477. """Set the end attribute of the given exception object to end. Return 0
  478. on success, -1 on failure."""
  479. raise NotImplementedError
  480. @cpython_api([PyObject], PyObject)
  481. def PyUnicodeDecodeError_GetReason(space, exc):
  482. """Return the reason attribute of the given exception object."""
  483. raise NotImplementedError
  484. @cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1)
  485. def PyUnicodeDecodeError_SetReason(space, exc, reason):
  486. """Set the reason attribute of the given exception object to reason. Return
  487. 0 on success, -1 on failure."""
  488. raise NotImplementedError
  489. @cpython_api([rffi.CCHARP], rffi.INT_real, error=1)
  490. def Py_EnterRecursiveCall(space, where):
  491. """Marks a point where a recursive C-level call is about to be performed.
  492. If USE_STACKCHECK is defined, this function checks if the the OS
  493. stack overflowed using PyOS_CheckStack(). In this is the case, it
  494. sets a MemoryError and returns a nonzero value.
  495. The function then checks if the recursion limit is reached. If this is the
  496. case, a RuntimeError is set and a nonzero value is returned.
  497. Otherwise, zero is returned.
  498. where should be a string such as " in instance check" to be
  499. concatenated to the RuntimeError message caused by the recursion depth
  500. limit."""
  501. raise NotImplementedError
  502. @cpython_api([], lltype.Void)
  503. def Py_LeaveRecursiveCall(space):
  504. """Ends a Py_EnterRecursiveCall(). Must be called once for each
  505. successful invocation of Py_EnterRecursiveCall()."""
  506. raise NotImplementedError
  507. @cpython_api([PyFileObject], lltype.Void)
  508. def PyFile_IncUseCount(space, p):
  509. """Increments the PyFileObject's internal use count to indicate
  510. that the underlying FILE* is being used.
  511. This prevents Python from calling f_close() on it from another thread.
  512. Callers of this must call PyFile_DecUseCount() when they are
  513. finished with the FILE*. Otherwise the file object will
  514. never be closed by Python.
  515. The GIL must be held while calling this function.
  516. The suggested use is to call this after PyFile_AsFile() and before
  517. you release the GIL:
  518. FILE *fp = PyFile_AsFile(p);
  519. PyFile_IncUseCount(p);
  520. /* ... */
  521. Py_BEGIN_ALLOW_THREADS
  522. do_something(fp);
  523. Py_END_ALLOW_THREADS
  524. /* ... */
  525. PyFile_DecUseCount(p);
  526. """
  527. raise NotImplementedError
  528. @cpython_api([PyFileObject], lltype.Void)
  529. def PyFile_DecUseCount(space, p):
  530. """Decrements the PyFileObject's internal unlocked_count member to
  531. indicate that the caller is done with its own use of the FILE*.
  532. This may only be called to undo a prior call to PyFile_IncUseCount().
  533. The GIL must be held while calling this function (see the example
  534. above).
  535. """
  536. raise NotImplementedError
  537. @cpython_api([PyFileObject, rffi.CCHARP], rffi.INT_real, error=0)
  538. def PyFile_SetEncoding(space, p, enc):
  539. """Set the file's encoding for Unicode output to enc. Return 1 on success and 0
  540. on failure.
  541. """
  542. raise NotImplementedError
  543. @cpython_api([PyFileObject, rffi.CCHARP, rffi.CCHARP], rffi.INT_real, error=0)
  544. def PyFile_SetEncodingAndErrors(space, p, enc, errors):
  545. """Set the file's encoding for Unicode output to enc, and its error
  546. mode to err. Return 1 on success and 0 on failure.
  547. """
  548. raise NotImplementedError
  549. @cpython_api([], PyObject)
  550. def PyFloat_GetInfo(space):
  551. """Return a structseq instance which contains information about the
  552. precision, minimum and maximum values of a float. It's a thin wrapper
  553. around the header file float.h.
  554. """
  555. raise NotImplementedError
  556. @cpython_api([], rffi.DOUBLE, error=CANNOT_FAIL)
  557. def PyFloat_GetMax(space):
  558. """Return the maximum representable finite float DBL_MAX as C double.
  559. """
  560. raise NotImplementedError
  561. @cpython_api([], rffi.DOUBLE, error=CANNOT_FAIL)
  562. def PyFloat_GetMin(space):
  563. """Return the minimum normalized positive float DBL_MIN as C double.
  564. """
  565. raise NotImplementedError
  566. @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
  567. def PyFloat_ClearFreeList(space):
  568. """Clear the float free list. Return the number of items that could not
  569. be freed.
  570. """
  571. raise NotImplementedError
  572. @cpython_api([rffi.CCHARP, PyFloatObject], lltype.Void)
  573. def PyFloat_AsString(space, buf, v):
  574. """Convert the argument v to a string, using the same rules as
  575. str(). The length of buf should be at least 100.
  576. This function is unsafe to call because it writes to a buffer whose
  577. length it does not know.
  578. Use PyObject_Str() or PyOS_double_to_string() instead."""
  579. raise NotImplementedError
  580. @cpython_api([rffi.CCHARP, PyFloatObject], lltype.Void)
  581. def PyFloat_AsReprString(space, buf, v):
  582. """Same as PyFloat_AsString, except uses the same rules as
  583. repr(). The length of buf should be at least 100.
  584. This function is unsafe to call because it writes to a buffer whose
  585. length it does not know.
  586. Use PyObject_Repr() or PyOS_double_to_string() instead."""
  587. raise NotImplementedError
  588. @cpython_api([PyObject, PyObject], PyObject)
  589. def PyFunction_New(space, code, globals):
  590. """Return a new function object associated with the code object code. globals
  591. must be a dictionary with the global variables accessible to the function.
  592. The function's docstring, name and __module__ are retrieved from the code
  593. object, the argument defaults and closure are set to NULL."""
  594. raise NotImplementedError
  595. @cpython_api([PyObject], PyObject)
  596. def PyFunction_GetGlobals(space, op):
  597. """Return the globals dictionary associated with the function object op."""
  598. borrow_from()
  599. raise NotImplementedError
  600. @cpython_api([PyObject], PyObject)
  601. def PyFunction_GetModule(space, op):
  602. """Return the __module__ attribute of the function object op. This is normally
  603. a string containing the module name, but can be set to any other object by
  604. Python code."""
  605. borrow_from()
  606. raise NotImplementedError
  607. @cpython_api([PyObject], PyObject)
  608. def PyFunction_GetDefaults(space, op):
  609. """Return the argument default values of the function object op. This can be a
  610. tuple of arguments or NULL."""
  611. borrow_from()
  612. raise NotImplementedError
  613. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  614. def PyFunction_SetDefaults(space, op, defaults):
  615. """Set the argument default values for the function object op. defaults must be
  616. Py_None or a tuple.
  617. Raises SystemError and returns -1 on failure."""
  618. raise NotImplementedError
  619. @cpython_api([PyObject], PyObject)
  620. def PyFunction_GetClosure(space, op):
  621. """Return the closure associated with the function object op. This can be NULL
  622. or a tuple of cell objects."""
  623. borrow_from()
  624. raise NotImplementedError
  625. @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
  626. def PyFunction_SetClosure(space, op, closure):
  627. """Set the closure associated with the function object op. closure must be
  628. Py_None or a tuple of cell objects.
  629. Raises SystemError and returns -1 on failure."""
  630. raise NotImplementedError
  631. @cpython_api([PyTypeObjectPtr, Py_ssize_t], PyObject)
  632. def PyObject_GC_NewVar(space, type, size):
  633. """Analogous to PyObject_NewVar() but for container objects with the
  634. Py_TPFLAGS_HAVE_GC flag set.
  635. This function used an int type for size. This might require
  636. changes in your code for properly supporting 64-bit systems."""
  637. raise NotImplementedError
  638. @cpython_api([PyObject, Py_ssize_t], PyObject)
  639. def PyObject_GC_Resize(space, op, newsize):
  640. """Resize an object allocated by PyObject_NewVar(). Returns the
  641. resized object or NULL on failure.
  642. This function used an int type for newsize. This might
  643. require changes in your code for properly supporting 64-bit systems."""
  644. raise NotImplementedError
  645. @cpython_api([PyObject], lltype.Void)
  646. def _PyObject_GC_TRACK(space, op):
  647. """A macro version of PyObject_GC_Track(). It should not be used for
  648. extension modules."""
  649. raise NotImplementedError
  650. @cpython_api([PyObject], lltype.Void)
  651. def _PyObject_GC_UNTRACK(space, op):
  652. """A macro version of PyObject_GC_UnTrack(). It should not be used for
  653. extension modules."""
  654. raise NotImplementedError
  655. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  656. def PyGen_Check(space, ob):
  657. """Return true if ob is a generator object; ob must not be NULL."""
  658. raise NotImplementedError
  659. @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
  660. def PyGen_CheckExact(space, ob):
  661. """Return true if ob's type is PyGen_Type is a generator object; ob must not
  662. be NULL."""
  663. raise NotImplementedError
  664. @cpython_api([PyFrameObject], PyObject)
  665. def PyGen_New(space, frame):
  666. """Create and return a new generator object based on the frame object. A
  667. reference to frame is stolen by this function. The parameter must not be
  668. NULL."""
  669. raise NotImplementedError
  670. @cpython_api([rffi.CCHARP, PyObject, PyObject, PyObject], PyObject)
  671. def PyImport_ImportModuleEx(space, name, globals, locals, fromlist):
  672. """Import a module. This is best described by referring to the built-in
  673. Python function __import__(), as the standard __import__() function calls
  674. this function directly.
  675. The return value is a new reference to the imported module or top-level package,
  676. or NULL with an exception set on failure (before Python 2.4, the module may
  677. still be created in this case). Like for __import__(), the return value
  678. when a submodule of a package was requested is normally the top-level package,
  679. unless a non-empty fromlist was given.
  680. Failing imports remove incomplete module objects.
  681. The function is an alias for PyImport_ImportModuleLevel() with
  682. -1 as level, meaning relative import."""
  683. raise NotImplementedError
  684. @cpython_api([rffi.CCHARP, PyObject, PyObject, PyObject, rffi.INT_real], PyObject)
  685. def PyImport_ImportModuleLevel(space, name, globals, locals, fromlist, level):
  686. """Import a module. This is best described by referring to the built-in Python
  687. function __import__(), as the standard __import__() function calls
  688. this function directly.
  689. The return value is a new reference to the imported module or top-level package,
  690. or NULL with an exception set on failure. Like for __import__(),
  691. the return value when a submodule of a package was requested is normally the
  692. top-level package, unless a non-empty fromlist was given.
  693. """
  694. raise NotImplementedError
  695. @cpython_api([], lltype.Signed, error=CANNOT_FAIL)
  696. def PyImport_GetMagicNumber(space):
  697. """Return the magic number for Python bytecode files (a.k.a. .pyc and
  698. .pyo files). The magic number should be present in the first four bytes
  699. of the bytecode file, in little-endian byte order."""
  700. raise NotImplementedError
  701. @cpython_api([PyObject], PyObject)
  702. def PyImport_GetImporter(space, path):
  703. """Return an importer object for a sys.path/pkg.__path__ item
  704. path, possibly by fetching it from the sys.path_importer_cache
  705. dict. If it wasn't yet cached, traverse sys.path_hooks until a hook
  706. is found that can handle the path item. Return None if no hook could;
  707. this tells our caller it should fall back to the built-in import mechanism.
  708. Cache the result in sys.path_importer_cache. Return a new reference
  709. to the importer object.
  710. """
  711. raise NotImplementedError
  712. @cpython_api([], lltype.Void)
  713. def _PyImport_Init(space):
  714. """Initialize the import mechanism. For internal use only."""
  715. raise NotImplementedError
  716. @cpython_api([], lltype.Void)
  717. def PyImport_Cleanup(space):
  718. """Empty the module table. For internal use only."""
  719. raise NotImplementedError
  720. @cpython_api([], lltype.Void)
  721. def _PyImport_Fini(space):
  722. """Finalize the import mechanism. For internal use only."""
  723. raise NotImplementedError
  724. @cpython_api([rffi.CCHARP, rffi.CCHARP], PyObject)
  725. def _PyImport_FindExtension(space, name, filename):
  726. """For internal use only."""
  727. raise NotImplementedError
  728. @cpython_api([rffi.CCHARP, rffi.CCHARP], PyObject)
  729. def _PyImport_FixupExtension(space, name, filename):
  730. """For internal use only."""
  731. raise NotImplementedError
  732. @cpython_api([rffi.CCHARP], rffi.INT_real, error=-1)
  733. def PyImport_ImportFrozenModule(space, name):
  734. """Load a frozen module named name. Return 1 for success, 0 if the
  735. module is not found, and -1 with an exception set if the initialization
  736. failed. To access the imported module on a successful load, use
  737. PyImport_ImportModule(). (Note the misnomer --- this function would
  738. reload the module if it was already imported.)"""
  739. raise NotImplementedError
  740. @cpython_api([rffi.CCHARP, rffi.VOIDP], rffi.INT_real, error=-1)
  741. def PyImport_AppendInittab(space, name, initfunc):
  742. """Add a single module to the existing table of built-in modules. This is a
  743. convenience wrapper around PyImport_ExtendInittab(), returning -1 if
  744. the table could not be extended. The new module can be imported by the name
  745. name, and uses the function initfunc as the initialization function called
  746. on the first attempted import. This should be called before
  747. Py_Initialize()."""
  748. raise NotImplementedError
  749. @cpython_api([_inittab], rffi.INT_real, error=-1)
  750. def PyImport_ExtendInittab(space, newtab):
  751. """Add a collection of modules to the table of built-in modules. The newtab
  752. array must end with a sentinel entry which contains NULL for the name
  753. field; failure to provide the sentinel value can result in a memory fault.
  754. Returns 0 on success or -1 if insufficient memory could be allocated to
  755. extend the internal table. In the event of failure, no modules are added to the
  756. internal table. This should be called before Py_Initialize()."""
  757. raise NotImplementedError
  758. @cpython_api([], lltype.Void)
  759. def Py_Initialize(space):
  760. """Initialize the Python interpreter. In an application embedding Python,
  761. this should be called before using any other Python/C API functions; with
  762. the exception of Py_SetProgramName(), PyEval_InitThreads(),
  763. PyEval_ReleaseLock(), and PyEval_AcquireLock(). This initializes the table
  764. of loaded modules (sys.modules), and creates the fundamental modules
  765. __builtin__, __main__ and sys. It also initializes the module search path
  766. (sys.path). It does not set sys.argv; use PySys_SetArgvEx() for that. This
  767. is a no-op when called for a second time (without calling Py_Finalize()
  768. first). There is no return value; it is a fatal error if the initialization
  769. fails."""
  770. raise NotImplementedError
  771. @cpython_api([rffi.INT_real], lltype.Void)
  772. def Py_InitializeEx(space, initsigs):
  773. """This function works like Py_Initialize() if initsigs is 1. If
  774. initsigs is 0, it skips initialization registration of signal handlers, which
  775. might be useful when Python is embedded.
  776. """
  777. raise NotImplementedError
  778. @cpython_api([], lltype.Void)
  779. def Py_Finalize(space):
  780. """Undo all initializations made by Py_Initialize() and subsequent use of
  781. Python/C API functions, and destroy all sub-interpreters (see
  782. Py_NewInterpreter() below) that were created and not yet destroyed since
  783. the last call to Py_Initialize(). Ideally, this frees all memory
  784. allocated by the Python interpreter. This is a no-op when called for a second
  785. time (without calling Py_Initialize() again first). There is no return
  786. value; errors during finalization are ignored.
  787. This function is provided for a number of reasons. An embedding application
  788. might want to restart Python without having to restart the application itself.
  789. An application that has loaded the Python interpreter from a dynamically
  790. loadable library (or DLL) might want to free all memory allocated by Python
  791. before unloading the DLL. During a hunt for memory leaks in an application a
  792. developer might want to free all memory allocated by Python before exiting from
  793. the application.
  794. Bugs and caveats: The destruction of modules and objects in modules is done
  795. in random order; this may cause destructors (__del__() methods) to fail
  796. when they depend on other objects (even functions) or modules. Dynamically
  797. loaded extension modules loaded by Python are not unloaded. Small amounts of
  798. memory allocated by the Python interpreter may not be freed (if you find a leak,
  799. please report it). Memory tied up in circular references between objects is not
  800. freed. Some memory allocated by extension modules may not be freed. Some
  801. extensions may not work properly if their initialization routine is called more
  802. than once; this can happen if an application calls Py_Initialize() and
  803. Py_Finalize() more than once."""
  804. raise NotImplementedError
  805. @cpython_api([rffi.CCHARP], lltype.Void)
  806. def Py_SetProgramName(space, name):
  807. """This function should be called before Py_Initialize() is called for the
  808. first time, if it is called at all. It tells the interpreter the value of
  809. the argv[0] argument to the main() function of the program. This is used by
  810. Py_GetPath() and some other functions below to find the Python run-time
  811. libraries relative to the interpreter executable. The default value is
  812. 'python'. The argument should point to a zero-terminated character string
  813. in static storage whose contents will not change for the duration of the
  814. program's execution. No code in the Python interpreter will change the
  815. contents of this storage."""
  816. raise NotImplementedError
  817. @cpython_api([], rffi.CCHARP)
  818. def Py_GetPrefix(space):
  819. """Return the prefix for installed platform-independent files. This is derived
  820. through a number of complicated rules from the program name set with
  821. Py_SetProgramName() and some environment variables; for example, if the
  822. program name is '/usr/local/bin/python', the prefix is '/usr/local'. The
  823. returned string points into static storage; the caller should not modify its
  824. value. This corresponds to the prefix variable in the top-level
  825. Makefile and the --prefix argument to the configure
  826. script at build time. The value is available to Python code as sys.prefix.
  827. It is only useful on Unix. See also the next function."""
  828. raise NotImplementedError
  829. @cpython_api([], rffi.CCHARP)
  830. def Py_GetExecPrefix(space):
  831. """Return the exec-prefix for installed platform-dependent files. This is
  832. derived through a number of complicated rules from the program name set with
  833. Py_SetProgramName() and some environment variables; for example, if the
  834. program name is '/usr/local/bin/python', the exec-prefix is
  835. '/usr/local'. The returned string points into static storage; the caller
  836. should not modify its value. This corresponds to the exec_prefix
  837. variable in the top-level Makefile and the --exec-prefix
  838. argument to the configure script at build time. The value is
  839. available to Python code as sys.exec_prefix. It is only useful on Unix.
  840. Background: The exec-prefix differs from the prefix when platform dependent
  841. files (such as executables and shared libraries) are installed in a different
  842. directory tree. In a typical installation, platform dependent files may be
  843. installed in the /usr/local/plat subtree while platform independent may
  844. be installed in /usr/local.
  845. Generally speaking, a platform is a combination of hardware and software
  846. families, e.g. Sparc machines running the Solaris 2.x operating system are
  847. considered the same platform, but Intel machines running Solaris 2.x are another
  848. platform, and Intel machines running Linux are yet another platform. Different
  849. major revisions of the same operating system generally also form different
  850. platforms. Non-Unix operating systems are a different story; the installation
  851. strategies on those systems are so different that the prefix and exec-prefix are
  852. meaningless, and set to the empty string. Note that compiled Python bytecode
  853. files are platform independent (but not independent from the Python version by
  854. which they were compiled!).
  855. System administrators will know how to configure the mount or
  856. automount programs to share /usr/local between platforms
  857. while having /usr/local/plat be a different filesystem for each
  858. platform."""
  859. raise NotImplementedError
  860. @cpython_api([], rffi.CCHARP)
  861. def Py_GetProgramFullPath(space):
  862. """Return the full program name of the Python executable; this is computed
  863. as a side-effect of deriving the default module search path from the program
  864. name (set by Py_SetProgramName() above). The returned string points into
  865. static storage; the caller should not modify its value. The value is
  866. available to Python code as sys.executable."""
  867. raise NotImplementedError
  868. @cpython_api([], rffi.CCHARP)
  869. def Py_GetPath(space):
  870. """Return the default module search path; this is computed from the program
  871. name (set by Py_SetProgramName() above) and some environment variables. The
  872. returned string consists of a series of directory names separated by a
  873. platform dependent delimiter character. The delimiter character is ':' on
  874. Unix and Mac OS X, ';' on Windows. The returned string points into static
  875. storage; the caller should not modify its value. The list sys.path is
  876. initialized with this value on interpreter startup; it can be (and usually
  877. is) modified later to change the search path for loading modules.
  878. XXX should give the exact rules"""
  879. raise NotImplementedError
  880. @cpython_api([], rffi.CCHARP)
  881. def Py_GetPlatform(space):
  882. """Return the platform identifier for the current platform. On Unix, this
  883. is formed from the"official" name of the operating system, converted to lower
  884. case, followed by the major revision number; e.g., for Solaris 2.x, which is
  885. also known as SunOS 5.x, the value is 'sunos5'. On Mac OS X, it is
  886. 'darwin'. On Windows, it is 'win'. The returned string points into
  887. static storage; the caller should not modify its value. The value is available
  888. to Python code as sys.platform."""
  889. raise NotImplementedError
  890. @cpython_api([], rffi.CCHARP)
  891. def Py_GetCopyright(space):
  892. """Return the official copyright string for the current Python version, for example
  893. 'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'
  894. The returned string points into static storage; the caller should not modify its
  895. value. The value is available to Python code as sys.copyright."""
  896. raise NotImplementedError
  897. @cpython_api([], rffi.CCHARP)
  898. def Py_GetCompiler(space):
  899. """Return an indication of the compiler used to build the current Python version,
  900. in square brackets, for example:
  901. "[GCC 2.7.2.2]"
  902. The returned string points into static storage; the caller should not modify its
  903. value. The value is available to Python code as part of the variable
  904. sys.version."""
  905. raise NotImplementedError
  906. @cpython_api([], rffi.CCHARP)
  907. def Py_GetBuildInfo(space):
  908. """Return information about the sequence number and build date and time of the
  909. current Python interpreter instance, for example
  910. "\#67, Aug 1 1997, 22:34:28"
  911. The returned string points into static storage; the caller should not modify its
  912. value. The value is available to Python code as part of the variable
  913. sys.version."""
  914. raise NotImplementedError
  915. @cpython_api([rffi.INT_real, rffi.CCHARPP, rffi.INT_real], lltype.Void)
  916. def PySys_SetArgvEx(space, argc, argv, updatepath):
  917. """Set sys.argv based on argc and argv. These parameters are similar to
  918. those passed to the program's main() function with the difference that the
  919. first entry should refer to the script file to be executed rather than the
  920. executable hosting the Python interpreter. If there isn't a script that
  921. will be run, the first entry in argv can be an empty string. If this
  922. function fails to initialize sys.argv, a fatal condition is signalled using
  923. Py_FatalError().
  924. If updatepath is zero, this is all the function does. If updatepath
  925. is non-zero, the function also modifies sys.path according to the
  926. following algorithm:
  927. If the name of an existing script is passed in argv[0], the absolute
  928. path of the directory where the script is located is prepended to
  929. sys.path.
  930. Otherwise (that is, if argc is 0 or argv[0] doesn't point
  931. to an existing file name), an empty string is prepended to
  932. sys.path, which is the same as prepending the current working
  933. directory (".").
  934. It is recommended that applications embedding the Python interpreter
  935. for purposes other than executing a single script pass 0 as updatepath,
  936. and update sys.path themselves if desired.
  937. See CVE-2008-5983.
  938. On versions before 2.6.6, you can achieve the same effect by manually
  939. popping the first sys.path element after having called
  940. PySys_SetArgv(), for example using:
  941. PyRun_SimpleString("import sys; sys.path.pop(0)\n");
  942. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
  943. check w/ Guido."""
  944. raise NotImplementedError
  945. @cpython_api([rffi.INT_real, rffi.CCHARPP], lltype.Void)
  946. def PySys_SetArgv(space, argc, argv):
  947. """This function works like PySys_SetArgvEx() with updatepath set to 1."""
  948. raise NotImplementedError
  949. @cpython_api([rffi.CCHARP], lltype.Void)
  950. def Py_SetPythonHome(space, home):
  951. """Set the default "home" directory, that is, the location of the standard
  952. Python libraries. See PYTHONHOME for the meaning of the
  953. argument string.
  954. The argument should point to a zero-terminated character string in static
  955. storage whose contents will not change for the duration of the program's
  956. execution. No code in the Python interpreter will change the contents of
  957. this storage."""
  958. raise NotImplementedError
  959. @cpython_api([], rffi.CCHARP)
  960. def Py_GetPythonHome(space):
  961. """Return the default "home", that is, the value set by a previous call to
  962. Py_SetPythonHome(), or the value of the PYTHONHOME
  963. environment variable if it is set."""
  964. raise NotImplementedError
  965. @cpython_api([], lltype.Void)
  966. def PyEval_ReInitThreads(space):
  967. """This function is called from PyOS_AfterFork() to ensure that newly
  968. created child processes don't hold locks referring to threads which
  969. are not

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