(_PyObject_New type)
Return value: New reference.
Return value: New reference.
(lookup-type-symbols)
Transform the static type-symbol-table map into a map of actual long pointer addresses to {:typename :type-symbol-name}
Transform the static type-symbol-table map into a map of actual long pointer addresses to {:typename :type-symbol-name}
(Py_DecRef py-obj)
Decrement the refference count on an object
Decrement the refference count on an object
(Py_False)
The Python False object. This object has no methods. It needs to be treated just like any other object with respect to reference counts.
The Python False object. This object has no methods. It needs to be treated just like any other object with respect to reference counts.
(Py_FinalizeEx)
Undo all initializations made by Py_Initialize() and subsequent use of Python/C API functions, and destroy all sub-interpreters (see Py_NewInterpreter() below) that were created and not yet destroyed since the last call to Py_Initialize(). Ideally, this frees all memory allocated by the Python interpreter. This is a no-op when called for a second time (without calling Py_Initialize() again first). There is no return value; errors during finalization are ignored.
Undo all initializations made by Py_Initialize() and subsequent use of Python/C API functions, and destroy all sub-interpreters (see Py_NewInterpreter() below) that were created and not yet destroyed since the last call to Py_Initialize(). Ideally, this frees all memory allocated by the Python interpreter. This is a no-op when called for a second time (without calling Py_Initialize() again first). There is no return value; errors during finalization are ignored.
(Py_IncRef py-obj)
Increment the reference count on an object
Increment the reference count on an object
(Py_InitializeEx initsigs)
This function works like Py_Initialize() if initsigs is 1. If initsigs is 0, it skips initialization registration of signal handlers, which might be useful when Python is embedded.
This function works like Py_Initialize() if initsigs is 1. If initsigs is 0, it skips initialization registration of signal handlers, which might be useful when Python is embedded.
(Py_IsInitialized)
Return true (nonzero) when the Python interpreter has been initialized, false (zero) if not. After Py_Finalize() is called, this returns false until Py_Initialize() is called again.
Return true (nonzero) when the Python interpreter has been initialized, false (zero) if not. After Py_Finalize() is called, this returns false until Py_Initialize() is called again.
(Py_True)
The Python True object. This object has no methods. It needs to be treated just like any other object with respect to reference counts.
The Python True object. This object has no methods. It needs to be treated just like any other object with respect to reference counts.
(PyBool_Check p)
Return true if o is of type PyBool_Type.
Return true if o is of type PyBool_Type.
(PyBool_FromLong v)
Return value: New reference.
Return a new reference to Py_True or Py_False depending on the truth value of v.
Return value: New reference. Return a new reference to Py_True or Py_False depending on the truth value of v.
(PyBuffer_IsContiguous view order)
Return 1 if the memory defined by the view is C-style (order is 'C') or Fortran-style (order is 'F') contiguous or either one (order is 'A'). Return 0 otherwise. This function always succeeds.
Return 1 if the memory defined by the view is C-style (order is 'C') or Fortran-style (order is 'F') contiguous or either one (order is 'A'). Return 0 otherwise. This function always succeeds.
(PyBuffer_Release view)
Release the buffer view and decrement the reference count for view->obj. This function MUST be called when the buffer is no longer being used, otherwise reference leaks may occur.
It is an error to call this function on a buffer that was not obtained via PyObject_GetBuffer().
Release the buffer view and decrement the reference count for view->obj. This function MUST be called when the buffer is no longer being used, otherwise reference leaks may occur. It is an error to call this function on a buffer that was not obtained via PyObject_GetBuffer().
(PyBuffer_ToContiguous buf src len order)
Copy len bytes from src to its contiguous representation in buf. order can be 'C' or 'F' (for C-style or Fortran-style ordering). 0 is returned on success, -1 on error.
This function fails if len != src->len.
Copy len bytes from src to its contiguous representation in buf. order can be 'C' or 'F' (for C-style or Fortran-style ordering). 0 is returned on success, -1 on error. This function fails if len != src->len.
(PyCallable_Check pyobj)
Determine if the object o is callable. Return 1 if the object is callable and 0 otherwise. This function always succeeds.
Determine if the object o is callable. Return 1 if the object is callable and 0 otherwise. This function always succeeds.
(PyCFunction_New method-def self)
Create a new callable from an item.
Create a new callable from an item.
(PyComplex_AsCComplex op)
Return the Py_complex value of the complex number op.
If op is not a Python complex number object but has a complex() method, this method will first be called to convert op to a Python complex number object. Upon failure, this method returns -1.0 as a real value.
Return the Py_complex value of the complex number op. If op is not a Python complex number object but has a __complex__() method, this method will first be called to convert op to a Python complex number object. Upon failure, this method returns -1.0 as a real value.
(PyComplex_Check p)
Return true if its argument is a PyComplexObject or a subtype of PyComplexObject.
Return true if its argument is a PyComplexObject or a subtype of PyComplexObject.
(PyComplex_FromCComplex v)
Return value: New reference.
Create a new Python complex number object from a C Py_complex value.
Return value: New reference. Create a new Python complex number object from a C Py_complex value.
(PyComplex_FromDoubles real imag)
Return value: New reference.
Return a new PyComplexObject object from real and imag.
Return value: New reference. Return a new PyComplexObject object from real and imag.
(PyComplex_ImagAsDouble op)
Return the imaginary part of op as a C double.
Return the imaginary part of op as a C double.
(PyComplex_RealAsDouble op)
Return the real part of op as a C double.
Return the real part of op as a C double.
(PyDict_Check p)
Return true if p is a dict object or an instance of a subtype of the dict type.
Return true if p is a dict object or an instance of a subtype of the dict type.
(PyDict_Clear p)
Empty an existing dictionary of all key-value pairs.
Empty an existing dictionary of all key-value pairs.
(PyDict_Contains p key)
Determine if dictionary p contains key. If an item in p is matches key, return 1, otherwise return 0. On error, return -1. This is equivalent to the Python expression key in p.
Determine if dictionary p contains key. If an item in p is matches key, return 1, otherwise return 0. On error, return -1. This is equivalent to the Python expression key in p.
(PyDict_Copy p)
Return value: New reference.
Return a new dictionary that contains the same key-value pairs as p.
Return value: New reference. Return a new dictionary that contains the same key-value pairs as p.
(PyDict_DelItem p key)
Remove the entry in dictionary p with key key. key must be hashable; if it isn’t, TypeError is raised. Return 0 on success or -1 on failure.
Remove the entry in dictionary p with key key. key must be hashable; if it isn’t, TypeError is raised. Return 0 on success or -1 on failure.
(PyDict_DelItemString p key)
Remove the entry in dictionary p which has a key specified by the string key. Return 0 on success or -1 on failure.
Remove the entry in dictionary p which has a key specified by the string key. Return 0 on success or -1 on failure.
(PyDict_GetItem p key)
Return value: Borrowed reference.
Return the object from dictionary p which has a key key. Return NULL if the key key is not present, but without setting an exception.
Note that exceptions which occur while calling hash() and eq() methods will get suppressed. To get error reporting use PyDict_GetItemWithError() instead.
Return value: Borrowed reference. Return the object from dictionary p which has a key key. Return NULL if the key key is not present, but without setting an exception. Note that exceptions which occur while calling __hash__() and __eq__() methods will get suppressed. To get error reporting use PyDict_GetItemWithError() instead.
(PyDict_GetItemString p key)
Return value: Borrowed reference.
This is the same as PyDict_GetItem(), but key is specified as a const char*, rather than a PyObject*.
Note that exceptions which occur while calling hash() and eq() methods and creating a temporary string object will get suppressed. To get error reporting use PyDict_GetItemWithError() instead.
Return value: Borrowed reference. This is the same as PyDict_GetItem(), but key is specified as a const char*, rather than a PyObject*. Note that exceptions which occur while calling __hash__() and __eq__() methods and creating a temporary string object will get suppressed. To get error reporting use PyDict_GetItemWithError() instead.
(PyDict_GetItemWithError p key)
Return value: Borrowed reference.
Variant of PyDict_GetItem() that does not suppress exceptions. Return NULL with an exception set if an exception occurred. Return NULL without an exception set if the key wasn’t present.
Return value: Borrowed reference. Variant of PyDict_GetItem() that does not suppress exceptions. Return NULL with an exception set if an exception occurred. Return NULL without an exception set if the key wasn’t present.
(PyDict_Items p)
Return value: New reference.
Return a PyListObject containing all the items from the dictionary.
Return value: New reference. Return a PyListObject containing all the items from the dictionary.
(PyDict_Keys p)
Return value: New reference.
Return a PyListObject containing all the keys from the dictionary.
Return value: New reference. Return a PyListObject containing all the keys from the dictionary.
(PyDict_Merge a b override)
Iterate over mapping object b adding key-value pairs to dictionary a. b may be a dictionary, or any object supporting PyMapping_Keys() and PyObject_GetItem(). If override is true, existing pairs in a will be replaced if a matching key is found in b, otherwise pairs will only be added if there is not a matching key in a. Return 0 on success or -1 if an exception was raised.
Iterate over mapping object b adding key-value pairs to dictionary a. b may be a dictionary, or any object supporting PyMapping_Keys() and PyObject_GetItem(). If override is true, existing pairs in a will be replaced if a matching key is found in b, otherwise pairs will only be added if there is not a matching key in a. Return 0 on success or -1 if an exception was raised.
(PyDict_MergeFromSeq2 a seq2 override)
Update or merge into dictionary a, from the key-value pairs in seq2. seq2 must be an iterable object producing iterable objects of length 2, viewed as key-value pairs. In case of duplicate keys, the last wins if override is true, else the first wins. Return 0 on success or -1 if an exception was raised. Equivalent Python (except for the return value): def PyDict_MergeFromSeq2(a, seq2, override): for key, value in seq2: if override or key not in a: a[key] = value
Update or merge into dictionary a, from the key-value pairs in seq2. seq2 must be an iterable object producing iterable objects of length 2, viewed as key-value pairs. In case of duplicate keys, the last wins if override is true, else the first wins. Return 0 on success or -1 if an exception was raised. Equivalent Python (except for the return value): def PyDict_MergeFromSeq2(a, seq2, override): for key, value in seq2: if override or key not in a: a[key] = value
(PyDict_New)
Return value: New reference.
Return a new empty dictionary, or NULL on failure.
Return value: New reference. Return a new empty dictionary, or NULL on failure.
(PyDict_Next p ppos pkey pvalue)
Iterate over all key-value pairs in the dictionary p. The Py_ssize_t referred to by ppos must be initialized to 0 prior to the first call to this function to start the iteration; the function returns true for each pair in the dictionary, and false once all pairs have been reported. The parameters pkey and pvalue should either point to PyObject* variables that will be filled in with each key and value, respectively, or may be NULL. Any references returned through them are borrowed. ppos should not be altered during iteration. Its value represents offsets within the internal dictionary structure, and since the structure is sparse, the offsets are not consecutive.
Iterate over all key-value pairs in the dictionary p. The Py_ssize_t referred to by ppos must be initialized to 0 prior to the first call to this function to start the iteration; the function returns true for each pair in the dictionary, and false once all pairs have been reported. The parameters pkey and pvalue should either point to PyObject* variables that will be filled in with each key and value, respectively, or may be NULL. Any references returned through them are borrowed. ppos should not be altered during iteration. Its value represents offsets within the internal dictionary structure, and since the structure is sparse, the offsets are not consecutive.
(PyDict_SetDefault p key defaultobj)
Return value: Borrowed reference.
This is the same as the Python-level dict.setdefault(). If present, it returns the value corresponding to key from the dictionary p. If the key is not in the dict, it is inserted with value defaultobj and defaultobj is returned. This function evaluates the hash function of key only once, instead of evaluating it independently for the lookup and the insertion.
New in version 3.4.
Return value: Borrowed reference. This is the same as the Python-level dict.setdefault(). If present, it returns the value corresponding to key from the dictionary p. If the key is not in the dict, it is inserted with value defaultobj and defaultobj is returned. This function evaluates the hash function of key only once, instead of evaluating it independently for the lookup and the insertion. New in version 3.4.
(PyDict_SetItem p key val)
Insert value into the dictionary p with a key of key. key must be hashable; if it isn’t, TypeError will be raised. Return 0 on success or -1 on failure.
Insert value into the dictionary p with a key of key. key must be hashable; if it isn’t, TypeError will be raised. Return 0 on success or -1 on failure.
(PyDict_SetItemString p key val)
Insert value into the dictionary p using key as a key. key should be a const char*. The key object is created using PyUnicode_FromString(key). Return 0 on success or -1 on failure.
Insert value into the dictionary p using key as a key. key should be a const char*. The key object is created using PyUnicode_FromString(key). Return 0 on success or -1 on failure.
(PyDict_Size p)
Return the number of items in the dictionary. This is equivalent to len(p) on a dictionary.
Return the number of items in the dictionary. This is equivalent to len(p) on a dictionary.
(PyDict_Update a b)
This is the same as PyDict_Merge(a, b, 1) in C, and is similar to a.update(b) in Python except that PyDict_Update() doesn’t fall back to the iterating over a sequence of key value pairs if the second argument has no “keys” attribute. Return 0 on success or -1 if an exception was raised.
This is the same as PyDict_Merge(a, b, 1) in C, and is similar to a.update(b) in Python except that PyDict_Update() doesn’t fall back to the iterating over a sequence of key value pairs if the second argument has no “keys” attribute. Return 0 on success or -1 if an exception was raised.
(PyDict_Values p)
Return value: New reference.
Return a PyListObject containing all the values from the dictionary p.
Return value: New reference. Return a PyListObject containing all the values from the dictionary p.
(PyDictProxy_New mapping)
Return value: New reference.
Return a types.MappingProxyType object for a mapping which enforces read-only behavior. This is normally used to create a view to prevent modification of the dictionary for non-dynamic class types.
Return value: New reference. Return a types.MappingProxyType object for a mapping which enforces read-only behavior. This is normally used to create a view to prevent modification of the dictionary for non-dynamic class types.
(PyErr_BadArgument)
This is a shorthand for PyErr_SetString(PyExc_TypeError, message), where message indicates that a built-in operation was invoked with an illegal argument. It is mostly for internal use.
This is a shorthand for PyErr_SetString(PyExc_TypeError, message), where message indicates that a built-in operation was invoked with an illegal argument. It is mostly for internal use.
(PyErr_BadInternalCall)
This is a shorthand for PyErr_SetString(PyExc_SystemError, message), where message indicates that an internal operation (e.g. a Python/C API function) was invoked with an illegal argument. It is mostly for internal use.
This is a shorthand for PyErr_SetString(PyExc_SystemError, message), where message indicates that an internal operation (e.g. a Python/C API function) was invoked with an illegal argument. It is mostly for internal use.
(PyErr_Clear)
Clear the error indicator. If the error indicator is not set, there is no effect.
Clear the error indicator. If the error indicator is not set, there is no effect.
(PyErr_Fetch ptype pvalue ptraceback)
Retrieve the error indicator into three variables whose addresses are passed. If the error indicator is not set, set all three variables to NULL. If it is set, it will be cleared and you own a reference to each object retrieved. The value and traceback object may be NULL even when the type object is not.
Note
This function is normally only used by code that needs to catch exceptions or by code that needs to save and restore the error indicator temporarily, e.g.:
{ PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback);
/* ... code that might produce other errors ... */
PyErr_Restore(type, value, traceback);
}
Retrieve the error indicator into three variables whose addresses are passed. If the error indicator is not set, set all three variables to NULL. If it is set, it will be cleared and you own a reference to each object retrieved. The value and traceback object may be NULL even when the type object is not. Note This function is normally only used by code that needs to catch exceptions or by code that needs to save and restore the error indicator temporarily, e.g.: { PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); /* ... code that might produce other errors ... */ PyErr_Restore(type, value, traceback); }
(PyErr_NoMemory)
Return value: Always NULL.
This is a shorthand for PyErr_SetNone(PyExc_MemoryError); it returns NULL so an object allocation function can write return PyErr_NoMemory(); when it runs out of memory.
Return value: Always NULL. This is a shorthand for PyErr_SetNone(PyExc_MemoryError); it returns NULL so an object allocation function can write return PyErr_NoMemory(); when it runs out of memory.
(PyErr_Occurred)
Check if the error indicator is set. If so, return the exception type.
Check if the error indicator is set. If so, return the exception type.
(PyErr_Print)
Alias for PyErr_PrintEx(1).
Alias for PyErr_PrintEx(1).
(PyErr_PrintEx set-sys-last-vars)
Print a standard traceback to sys.stderr and clear the error indicator. Unless the error is a SystemExit. In that case the no traceback is printed and Python process will exit with the error code specified by the SystemExit instance.
Call this function only when the error indicator is set. Otherwise it will cause a fatal error!
If set_sys_last_vars is nonzero, the variables sys.last_type, sys.last_value and sys.last_traceback will be set to the type, value and traceback of the printed exception, respectively.
Print a standard traceback to sys.stderr and clear the error indicator. Unless the error is a SystemExit. In that case the no traceback is printed and Python process will exit with the error code specified by the SystemExit instance. Call this function only when the error indicator is set. Otherwise it will cause a fatal error! If set_sys_last_vars is nonzero, the variables sys.last_type, sys.last_value and sys.last_traceback will be set to the type, value and traceback of the printed exception, respectively.
(PyErr_Restore value traceback)
Set the error indicator from the three objects. If the error indicator is already set, it is cleared first. If the objects are NULL, the error indicator is cleared. Do not pass a NULL type and non-NULL value or traceback. The exception type should be a class. Do not pass an invalid exception type or value. (Violating these rules will cause subtle problems later.) This call takes away a reference to each object: you must own a reference to each object before the call and after the call you no longer own these references. (If you don’t understand this, don’t use this function. I warned you.)
Note
This function is normally only used by code that needs to save and restore the error indicator temporarily. Use PyErr_Fetch() to save the current error indicator.
Set the error indicator from the three objects. If the error indicator is already set, it is cleared first. If the objects are NULL, the error indicator is cleared. Do not pass a NULL type and non-NULL value or traceback. The exception type should be a class. Do not pass an invalid exception type or value. (Violating these rules will cause subtle problems later.) This call takes away a reference to each object: you must own a reference to each object before the call and after the call you no longer own these references. (If you don’t understand this, don’t use this function. I warned you.) Note This function is normally only used by code that needs to save and restore the error indicator temporarily. Use PyErr_Fetch() to save the current error indicator.
(PyErr_SetFromErrno type)
Return value: Always NULL.
This is a convenience function to raise an exception when a C library function has returned an error and set the C variable errno. It constructs a tuple object whose first item is the integer errno value and whose second item is the corresponding error message (gotten from strerror()), and then calls PyErr_SetObject(type, object). On Unix, when the errno value is EINTR, indicating an interrupted system call, this calls PyErr_CheckSignals(), and if that set the error indicator, leaves it set to that. The function always returns NULL, so a wrapper function around a system call can write return PyErr_SetFromErrno(type); when the system call returns an error.
Return value: Always NULL. This is a convenience function to raise an exception when a C library function has returned an error and set the C variable errno. It constructs a tuple object whose first item is the integer errno value and whose second item is the corresponding error message (gotten from strerror()), and then calls PyErr_SetObject(type, object). On Unix, when the errno value is EINTR, indicating an interrupted system call, this calls PyErr_CheckSignals(), and if that set the error indicator, leaves it set to that. The function always returns NULL, so a wrapper function around a system call can write return PyErr_SetFromErrno(type); when the system call returns an error.
(PyErr_SetNone type)
This is a shorthand for PyErr_SetObject(type, Py_None).
This is a shorthand for PyErr_SetObject(type, Py_None).
(PyErr_SetObject type value)
This function is similar to PyErr_SetString() but lets you specify an arbitrary Python object for the “value” of the exception.
This function is similar to PyErr_SetString() but lets you specify an arbitrary Python object for the “value” of the exception.
(PyErr_SetString type message)
This is the most common way to set the error indicator. The first argument specifies the exception type; it is normally one of the standard exceptions, e.g. PyExc_RuntimeError. You need not increment its reference count. The second argument is an error message; it is decoded from 'utf-8’.
This is the most common way to set the error indicator. The first argument specifies the exception type; it is normally one of the standard exceptions, e.g. PyExc_RuntimeError. You need not increment its reference count. The second argument is an error message; it is decoded from 'utf-8’.
(PyErr_WarnEx category message stack_level)
Issue a warning message. The category argument is a warning category (see below) or NULL; the message argument is a UTF-8 encoded string. stack_level is a positive number giving a number of stack frames; the warning will be issued from the currently executing line of code in that stack frame. A stack_level of 1 is the function calling PyErr_WarnEx(), 2 is the function above that, and so forth.
Warning categories must be subclasses of PyExc_Warning; PyExc_Warning is a subclass of PyExc_Exception; the default warning category is PyExc_RuntimeWarning. The standard Python warning categories are available as global variables whose names are enumerated at Standard Warning Categories.
For information about warning control, see the documentation for the warnings module and the -W option in the command line documentation. There is no C API for warning control.
Issue a warning message. The category argument is a warning category (see below) or NULL; the message argument is a UTF-8 encoded string. stack_level is a positive number giving a number of stack frames; the warning will be issued from the currently executing line of code in that stack frame. A stack_level of 1 is the function calling PyErr_WarnEx(), 2 is the function above that, and so forth. Warning categories must be subclasses of PyExc_Warning; PyExc_Warning is a subclass of PyExc_Exception; the default warning category is PyExc_RuntimeWarning. The standard Python warning categories are available as global variables whose names are enumerated at Standard Warning Categories. For information about warning control, see the documentation for the warnings module and the -W option in the command line documentation. There is no C API for warning control.
(PyErr_WarnExplicit category message filename lineno module registry)
Similar to PyErr_WarnExplicitObject() except that message and module are UTF-8 encoded strings, and filename is decoded from the filesystem encoding (os.fsdecode()).
Similar to PyErr_WarnExplicitObject() except that message and module are UTF-8 encoded strings, and filename is decoded from the filesystem encoding (os.fsdecode()).
(PyErr_WriteUnraisable obj)
This utility function prints a warning message to sys.stderr when an exception has been set but it is impossible for the interpreter to actually raise the exception. It is used, for example, when an exception occurs in an del() method.
The function is called with a single argument obj that identifies the context in which the unraisable exception occurred. If possible, the repr of obj will be printed in the warning message.
An exception must be set when calling this function.
This utility function prints a warning message to sys.stderr when an exception has been set but it is impossible for the interpreter to actually raise the exception. It is used, for example, when an exception occurs in an __del__() method. The function is called with a single argument obj that identifies the context in which the unraisable exception occurred. If possible, the repr of obj will be printed in the warning message. An exception must be set when calling this function.
(PyEval_RestoreThread tstate)
Acquire the global interpreter lock (if it has been created and thread support is enabled) and set the thread state to tstate, which must not be NULL. If the lock has been created, the current thread must not have acquired it, otherwise deadlock ensues.
Note
Calling this function from a thread when the runtime is finalizing will terminate the thread, even if the thread was not created by Python. You can use _Py_IsFinalizing() or sys.is_finalizing() to check if the interpreter is in process of being finalized before calling this function to avoid unwanted termination.
Acquire the global interpreter lock (if it has been created and thread support is enabled) and set the thread state to tstate, which must not be NULL. If the lock has been created, the current thread must not have acquired it, otherwise deadlock ensues. Note Calling this function from a thread when the runtime is finalizing will terminate the thread, even if the thread was not created by Python. You can use _Py_IsFinalizing() or sys.is_finalizing() to check if the interpreter is in process of being finalized before calling this function to avoid unwanted termination.
(PyEval_SaveThread)
Release the global interpreter lock (if it has been created and thread support is enabled) and reset the thread state to NULL, returning the previous thread state (which is not NULL). If the lock has been created, the current thread must have acquired it.
Release the global interpreter lock (if it has been created and thread support is enabled) and reset the thread state to NULL, returning the previous thread state (which is not NULL). If the lock has been created, the current thread must have acquired it.
(PyException_GetCause ex)
Return value: New reference.
Return the cause (either an exception instance, or None, set by raise ... from ...) associated with the exception as a new reference, as accessible from Python through cause.
Return value: New reference. Return the cause (either an exception instance, or None, set by raise ... from ...) associated with the exception as a new reference, as accessible from Python through __cause__.
(PyException_GetContext ex)
Return value: New reference.
Return the context (another exception instance during whose handling ex was raised) associated with the exception as a new reference, as accessible from Python through context. If there is no context associated, this returns NULL.
Return value: New reference. Return the context (another exception instance during whose handling ex was raised) associated with the exception as a new reference, as accessible from Python through __context__. If there is no context associated, this returns NULL.
(PyException_GetTraceback ex)
Return value: New reference.
Return the traceback associated with the exception as a new reference, as accessible from Python through traceback. If there is no traceback associated, this returns NULL.
Return value: New reference. Return the traceback associated with the exception as a new reference, as accessible from Python through __traceback__. If there is no traceback associated, this returns NULL.
(PyException_SetCause ex cause)
Set the cause associated with the exception to cause. Use NULL to clear it. There is no type check to make sure that cause is either an exception instance or None. This steals a reference to cause.
suppress_context is implicitly set to True by this function.
Set the cause associated with the exception to cause. Use NULL to clear it. There is no type check to make sure that cause is either an exception instance or None. This steals a reference to cause. __suppress_context__ is implicitly set to True by this function.
(PyException_SetContext ex ctx)
Set the context associated with the exception to ctx. Use NULL to clear it. There is no type check to make sure that ctx is an exception instance. This steals a reference to ctx.
Set the context associated with the exception to ctx. Use NULL to clear it. There is no type check to make sure that ctx is an exception instance. This steals a reference to ctx.
(PyException_SetTraceback ex tb)
Set the traceback associated with the exception to tb. Use Py_None to clear it.
Set the traceback associated with the exception to tb. Use Py_None to clear it.
(PyFloat_AsDouble v)
Return a C double representation of the contents of pyfloat. If pyfloat is not a Python floating point object but has a float() method, this method will first be called to convert pyfloat into a float. This method returns -1.0 upon failure, so one should call PyErr_Occurred() to check for errors.
Return a C double representation of the contents of pyfloat. If pyfloat is not a Python floating point object but has a __float__() method, this method will first be called to convert pyfloat into a float. This method returns -1.0 upon failure, so one should call PyErr_Occurred() to check for errors.
(PyFloat_Check p)
Return true if its argument is a PyFloatObject or a subtype of PyFloatObject.
Return true if its argument is a PyFloatObject or a subtype of PyFloatObject.
(PyFloat_CheckExact p)
Return true if its argument is a PyFloatObject, but not a subtype of PyFloatObject.
Return true if its argument is a PyFloatObject, but not a subtype of PyFloatObject.
(PyFloat_FromDouble v)
Return value: New reference.
Create a PyFloatObject object from v, or NULL on failure.
Return value: New reference. Create a PyFloatObject object from v, or NULL on failure.
(PyFloat_FromString str)
Return value: New reference.
Create a PyFloatObject object based on the string value in str, or NULL on failure.
Return value: New reference. Create a PyFloatObject object based on the string value in str, or NULL on failure.
(PyFloat_GetInfo)
Return value: New reference.
Return a structseq instance which contains information about the precision, minimum and maximum values of a float. It’s a thin wrapper around the header file float.h.
Return value: New reference. Return a structseq instance which contains information about the precision, minimum and maximum values of a float. It’s a thin wrapper around the header file float.h.
(PyFloat_GetMax)
Return the maximum representable finite float DBL_MAX as C double.
Return the maximum representable finite float DBL_MAX as C double.
(PyFloat_GetMin)
Return the minimum normalized positive float DBL_MIN as C double.
Return the minimum normalized positive float DBL_MIN as C double.
(PyFrozenSet_Check p)
Return true if p is a frozenset object or an instance of a subtype.
Return true if p is a frozenset object or an instance of a subtype.
(PyFrozenSet_New iterable)
Return value: New reference.
Return a new frozenset containing objects returned by the iterable. The iterable may be NULL to create a new empty frozenset. Return the new set on success or NULL on failure. Raise TypeError if iterable is not actually iterable.
Return value: New reference. Return a new frozenset containing objects returned by the iterable. The iterable may be NULL to create a new empty frozenset. Return the new set on success or NULL on failure. Raise TypeError if iterable is not actually iterable.
(PyImport_AddModule name)
Return value: Borrowed reference.
Similar to PyImport_AddModuleObject(), but the name is a UTF-8 encoded string instead of a Unicode object.
Return value: Borrowed reference. Similar to PyImport_AddModuleObject(), but the name is a UTF-8 encoded string instead of a Unicode object.
(PyImport_GetModuleDict)
Return value: Borrowed reference.
Return the dictionary used for the module administration (a.k.a. sys.modules). Note that this is a per-interpreter variable.
Return value: Borrowed reference. Return the dictionary used for the module administration (a.k.a. sys.modules). Note that this is a per-interpreter variable.
(PyImport_Import name)
Return value: New reference.
This is a higher-level interface that calls the current “import hook function” (with an explicit level of 0, meaning absolute import). It invokes the import() function from the builtins of the current globals. This means that the import is done using whatever import hooks are installed in the current environment.
This function always uses absolute imports.
Return value: New reference. This is a higher-level interface that calls the current “import hook function” (with an explicit level of 0, meaning absolute import). It invokes the __import__() function from the __builtins__ of the current globals. This means that the import is done using whatever import hooks are installed in the current environment. This function always uses absolute imports.
(PyImport_ImportModule name)
Return value: New reference.
This is a simplified interface to PyImport_ImportModuleEx() below, leaving the globals and locals arguments set to NULL and level set to 0. When the name argument contains a dot (when it specifies a submodule of a package), the fromlist argument is set to the list ['*'] so that the return value is the named module rather than the top-level package containing it as would otherwise be the case. (Unfortunately, this has an additional side effect when name in fact specifies a subpackage instead of a submodule: the submodules specified in the package’s all variable are loaded.) Return a new reference to the imported module, or NULL with an exception set on failure. A failing import of a module doesn’t leave the module in sys.modules.
This function always uses absolute imports.
Return value: New reference. This is a simplified interface to PyImport_ImportModuleEx() below, leaving the globals and locals arguments set to NULL and level set to 0. When the name argument contains a dot (when it specifies a submodule of a package), the fromlist argument is set to the list ['*'] so that the return value is the named module rather than the top-level package containing it as would otherwise be the case. (Unfortunately, this has an additional side effect when name in fact specifies a subpackage instead of a submodule: the submodules specified in the package’s __all__ variable are loaded.) Return a new reference to the imported module, or NULL with an exception set on failure. A failing import of a module doesn’t leave the module in sys.modules. This function always uses absolute imports.
(PyImport_ImportModuleLevel name globals locals fromlist level)
Return value: New reference.
Similar to PyImport_ImportModuleLevelObject(), but the name is a UTF-8 encoded
string instead of a Unicode object.
Changed in version 3.3: Negative values for level are no longer accepted.
(documentation from python import function import(name, globals=None, locals=None, fromlist=(), level=0)
This function is invoked by the import statement. It can be replaced (by importing the builtins module and assigning to builtins.import) in order to change semantics of the import statement, but doing so is strongly discouraged as it is usually simpler to use import hooks (see PEP 302) to attain the same goals and does not cause issues with code which assumes the default import implementation is in use. Direct use of import() is also discouraged in favor of importlib.import_module().
The function imports the module name, potentially using the given globals and locals to determine how to interpret the name in a package context. The fromlist gives the names of objects or submodules that should be imported from the module given by name. The standard implementation does not use its locals argument at all, and uses its globals only to determine the package context of the import statement.
level specifies whether to use absolute or relative imports. 0 (the default) means only perform absolute imports. Positive values for level indicate the number of parent directories to search relative to the directory of the module calling import() (see PEP 328 for the details).
When the name variable is of the form package.module, normally, the top-level package (the name up till the first dot) is returned, not the module named by name. However, when a non-empty fromlist argument is given, the module named by name is returned.
For example, the statement import spam results in bytecode resembling the following code:
spam = import('spam', globals(), locals(), [], 0)
The statement import spam.ham results in this call:
spam = import('spam.ham', globals(), locals(), [], 0)
Note how import() returns the toplevel module here because this is the object that is bound to a name by the import statement.
On the other hand, the statement from spam.ham import eggs, sausage as saus results in
_temp = import('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0) eggs = _temp.eggs saus = _temp.sausage
Here, the spam.ham module is returned from import(). From this object, the names to import are retrieved and assigned to their respective names.
If you simply want to import a module (potentially within a package) by name, use importlib.import_module().
Changed in version 3.3: Negative values for level are no longer supported (which also changes the default value to 0).
Return value: New reference. Similar to PyImport_ImportModuleLevelObject(), but the name is a UTF-8 encoded string instead of a Unicode object. Changed in version 3.3: Negative values for level are no longer accepted. (documentation from python __import__ function __import__(name, globals=None, locals=None, fromlist=(), level=0) This function is invoked by the import statement. It can be replaced (by importing the builtins module and assigning to builtins.__import__) in order to change semantics of the import statement, but doing so is strongly discouraged as it is usually simpler to use import hooks (see PEP 302) to attain the same goals and does not cause issues with code which assumes the default import implementation is in use. Direct use of __import__() is also discouraged in favor of importlib.import_module(). The function imports the module name, potentially using the given globals and locals to determine how to interpret the name in a package context. The fromlist gives the names of objects or submodules that should be imported from the module given by name. The standard implementation does not use its locals argument at all, and uses its globals only to determine the package context of the import statement. level specifies whether to use absolute or relative imports. 0 (the default) means only perform absolute imports. Positive values for level indicate the number of parent directories to search relative to the directory of the module calling __import__() (see PEP 328 for the details). When the name variable is of the form package.module, normally, the top-level package (the name up till the first dot) is returned, not the module named by name. However, when a non-empty fromlist argument is given, the module named by name is returned. For example, the statement import spam results in bytecode resembling the following code: spam = __import__('spam', globals(), locals(), [], 0) The statement import spam.ham results in this call: spam = __import__('spam.ham', globals(), locals(), [], 0) Note how __import__() returns the toplevel module here because this is the object that is bound to a name by the import statement. On the other hand, the statement from spam.ham import eggs, sausage as saus results in _temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0) eggs = _temp.eggs saus = _temp.sausage Here, the spam.ham module is returned from __import__(). From this object, the names to import are retrieved and assigned to their respective names. If you simply want to import a module (potentially within a package) by name, use importlib.import_module(). Changed in version 3.3: Negative values for level are no longer supported (which also changes the default value to 0).
(PyIter_Check o)
Return true if the object o supports the iterator protocol.
Return true if the object o supports the iterator protocol.
(PyIter_Next o)
Return value: New reference.
Return the next value from the iteration o. The object must be an iterator (it is up to the caller to check this). If there are no remaining values, returns NULL with no exception set. If an error occurs while retrieving the item, returns NULL and passes along the exception.
Return value: New reference. Return the next value from the iteration o. The object must be an iterator (it is up to the caller to check this). If there are no remaining values, returns NULL with no exception set. If an error occurs while retrieving the item, returns NULL and passes along the exception.
(PyList_Append list item)
Append the object item at the end of list list. Return 0 if successful; return -1 and set an exception if unsuccessful. Analogous to list.append(item).
Append the object item at the end of list list. Return 0 if successful; return -1 and set an exception if unsuccessful. Analogous to list.append(item).
(PyList_AsTuple list)
Return value: New reference.
Return a new tuple object containing the contents of list; equivalent to tuple(list).
Return value: New reference. Return a new tuple object containing the contents of list; equivalent to tuple(list).
(PyList_Check p)
Return true if p is a list object or an instance of a subtype of the list type.
Return true if p is a list object or an instance of a subtype of the list type.
(PyList_GetItem list index)
Return value: Borrowed reference.
Return the object at position index in the list pointed to by list. The position must be positive, indexing from the end of the list is not supported. If index is out of bounds, return NULL and set an IndexError exception.
Return value: Borrowed reference. Return the object at position index in the list pointed to by list. The position must be positive, indexing from the end of the list is not supported. If index is out of bounds, return NULL and set an IndexError exception.
(PyList_GetSlice list low high)
Return value: New reference.
Return a list of the objects in list containing the objects between low and high. Return NULL and set an exception if unsuccessful. Analogous to list[low:high]. Negative indices, as when slicing from Python, are not supported.
Return value: New reference. Return a list of the objects in list containing the objects between low and high. Return NULL and set an exception if unsuccessful. Analogous to list[low:high]. Negative indices, as when slicing from Python, are not supported.
(PyList_Insert list index item)
Insert the item item into list list in front of index index. Return 0 if successful; return -1 and set an exception if unsuccessful. Analogous to list.insert(index, item).
Insert the item item into list list in front of index index. Return 0 if successful; return -1 and set an exception if unsuccessful. Analogous to list.insert(index, item).
(PyList_New len)
Return value: New reference.
Return a new list of length len on success, or NULL on failure.
Note
If len is greater than zero, the returned list object’s items are set to NULL. Thus you cannot use abstract API functions such as PySequence_SetItem() or expose the object to Python code before setting all items to a real object with PyList_SetItem().
Return value: New reference. Return a new list of length len on success, or NULL on failure. Note If len is greater than zero, the returned list object’s items are set to NULL. Thus you cannot use abstract API functions such as PySequence_SetItem() or expose the object to Python code before setting all items to a real object with PyList_SetItem().
(PyList_Reverse list)
Reverse the items of list in place. Return 0 on success, -1 on failure. This is the equivalent of list.reverse().
Reverse the items of list in place. Return 0 on success, -1 on failure. This is the equivalent of list.reverse().
(PyList_SetItem list index item)
Set the item at index index in list to item. Return 0 on success or -1 on failure.
Note
This function “steals” a reference to item and discards a reference to an item already in the list at the affected position.
Set the item at index index in list to item. Return 0 on success or -1 on failure. Note This function “steals” a reference to item and discards a reference to an item already in the list at the affected position.
(PyList_SetSlice list low high itemlist)
Set the slice of list between low and high to the contents of itemlist. Analogous to list[low:high] = itemlist. The itemlist may be NULL, indicating the assignment of an empty list (slice deletion). Return 0 on success, -1 on failure. Negative indices, as when slicing from Python, are not supported.
Set the slice of list between low and high to the contents of itemlist. Analogous to list[low:high] = itemlist. The itemlist may be NULL, indicating the assignment of an empty list (slice deletion). Return 0 on success, -1 on failure. Negative indices, as when slicing from Python, are not supported.
(PyList_Size list)
Return the length of the list object in list; this is equivalent to len(list) on a list object.
Return the length of the list object in list; this is equivalent to len(list) on a list object.
(PyList_Sort list)
Sort the items of list in place. Return 0 on success, -1 on failure. This is equivalent to list.sort().
Sort the items of list in place. Return 0 on success, -1 on failure. This is equivalent to list.sort().
(PyLong_AsLong obj)
Return a C long representation of obj. If obj is not an instance of PyLongObject, first call its int() method (if present) to convert it to a PyLongObject.
Raise OverflowError if the value of obj is out of range for a long.
Returns -1 on error. Use PyErr_Occurred() to disambiguate.
Return a C long representation of obj. If obj is not an instance of PyLongObject, first call its __int__() method (if present) to convert it to a PyLongObject. Raise OverflowError if the value of obj is out of range for a long. Returns -1 on error. Use PyErr_Occurred() to disambiguate.
(PyLong_AsLongLong obj)
Return a C long long representation of obj. If obj is not an instance of PyLongObject, first call its int() method (if present) to convert it to a PyLongObject.
Raise OverflowError if the value of obj is out of range for a long.
Returns -1 on error. Use PyErr_Occurred() to disambiguate.
Return a C long long representation of obj. If obj is not an instance of PyLongObject, first call its __int__() method (if present) to convert it to a PyLongObject. Raise OverflowError if the value of obj is out of range for a long. Returns -1 on error. Use PyErr_Occurred() to disambiguate.
(PyLong_Check p)
Return true if its argument is a PyLongObject or a subtype of PyLongObject.
Return true if its argument is a PyLongObject or a subtype of PyLongObject.
(PyLong_CheckExact p)
Return true if its argument is a PyLongObject, but not a subtype of PyLongObject.
Return true if its argument is a PyLongObject, but not a subtype of PyLongObject.
(PyLong_FromDouble v)
Return value: New reference.
Return a new PyLongObject object from the integer part of v, or NULL on failure.
Return value: New reference. Return a new PyLongObject object from the integer part of v, or NULL on failure.
(PyLong_FromLong v)
Return value: New reference.
Return a new PyLongObject object from v, or NULL on failure.
The current implementation keeps an array of integer objects for all integers between -5 and 256, when you create an int in that range you actually just get back a reference to the existing object. So it should be possible to change the value of
Return value: New reference. Return a new PyLongObject object from v, or NULL on failure. The current implementation keeps an array of integer objects for all integers between -5 and 256, when you create an int in that range you actually just get back a reference to the existing object. So it should be possible to change the value of 1. I suspect the behaviour of Python in this case is undefined. :-)
(PyLong_FromLongLong v)
Return value: New reference.
Return a new PyLongObject object from a C long long, or NULL on failure.
Return value: New reference. Return a new PyLongObject object from a C long long, or NULL on failure.
(PyLong_FromSsize_t v)
Return value: New reference.
Return a new PyLongObject object from a C Py_ssize_t, or NULL on failure.
Return value: New reference. Return a new PyLongObject object from a C Py_ssize_t, or NULL on failure.
(PyLong_FromUnsignedLong v)
Return value: New reference.
Return a new PyLongObject object from a C unsigned long, or NULL on failure.
Return value: New reference. Return a new PyLongObject object from a C unsigned long, or NULL on failure.
(PyLong_FromUnsignedLongLong v)
Return value: New reference.
Return a new PyLongObject object from a C unsigned long long, or NULL on failure.
Return value: New reference. Return a new PyLongObject object from a C unsigned long long, or NULL on failure.
(PyMapping_Check o)
Return 1 if the object provides mapping protocol or supports slicing, and 0 otherwise. Note that it returns 1 for Python classes with a getitem() method since in general case it is impossible to determine what the type of keys it supports. This function always succeeds.
Return 1 if the object provides mapping protocol or supports slicing, and 0 otherwise. Note that it returns 1 for Python classes with a __getitem__() method since in general case it is impossible to determine what the type of keys it supports. This function always succeeds.
(PyMapping_DelItem o key)
Remove the mapping for the object key from the object o. Return -1 on failure. This is equivalent to the Python statement del o[key]. This is an alias of PyObject_DelItem().
Remove the mapping for the object key from the object o. Return -1 on failure. This is equivalent to the Python statement del o[key]. This is an alias of PyObject_DelItem().
(PyMapping_DelItemString o key)
Remove the mapping for the string key from the object o. Return -1 on failure. This is equivalent to the Python statement del o[key].
Remove the mapping for the string key from the object o. Return -1 on failure. This is equivalent to the Python statement del o[key].
(PyMapping_GetItemString o key)
Return value: New reference.
Return element of o corresponding to the string key or NULL on failure. This is the equivalent of the Python expression o[key]. See also PyObject_GetItem().
Return value: New reference. Return element of o corresponding to the string key or NULL on failure. This is the equivalent of the Python expression o[key]. See also PyObject_GetItem().
(PyMapping_HasKey o key)
Return 1 if the mapping object has the key key and 0 otherwise. This is equivalent to the Python expression key in o. This function always succeeds.
Note that exceptions which occur while calling the getitem() method will get suppressed. To get error reporting use PyObject_GetItem() instead.
Return 1 if the mapping object has the key key and 0 otherwise. This is equivalent to the Python expression key in o. This function always succeeds. Note that exceptions which occur while calling the __getitem__() method will get suppressed. To get error reporting use PyObject_GetItem() instead.
(PyMapping_HasKeyString o key)
Return 1 if the mapping object has the key key and 0 otherwise. This is equivalent to the Python expression key in o. This function always succeeds.
Note that exceptions which occur while calling the getitem() method and creating a temporary string object will get suppressed. To get error reporting use PyMapping_GetItemString() instead.
Return 1 if the mapping object has the key key and 0 otherwise. This is equivalent to the Python expression key in o. This function always succeeds. Note that exceptions which occur while calling the __getitem__() method and creating a temporary string object will get suppressed. To get error reporting use PyMapping_GetItemString() instead.
(PyMapping_Items o)
Return value: New reference.
On success, return a list of the items in object o, where each item is a tuple containing a key-value pair. On failure, return NULL.
Changed in version 3.7: Previously, the function returned a list or a tuple.
Return value: New reference. On success, return a list of the items in object o, where each item is a tuple containing a key-value pair. On failure, return NULL. Changed in version 3.7: Previously, the function returned a list or a tuple.
(PyMapping_Keys o)
Return value: New reference.
On success, return a list of the keys in object o. On failure, return NULL.
Changed in version 3.7: Previously, the function returned a list or a tuple.
Return value: New reference. On success, return a list of the keys in object o. On failure, return NULL. Changed in version 3.7: Previously, the function returned a list or a tuple.
(PyMapping_Length o)
Returns the number of keys in object o on success, and -1 on failure. This is equivalent to the Python expression len(o).
Returns the number of keys in object o on success, and -1 on failure. This is equivalent to the Python expression len(o).
(PyMapping_SetItemString o key v)
Map the string key to the value v in object o. Returns -1 on failure. This is the equivalent of the Python statement o[key] = v. See also PyObject_SetItem().
Map the string key to the value v in object o. Returns -1 on failure. This is the equivalent of the Python statement o[key] = v. See also PyObject_SetItem().
(PyMapping_Values o)
Return value: New reference.
On success, return a list of the values in object o. On failure, return NULL.
Changed in version 3.7: Previously, the function returned a list or a tuple.
Return value: New reference. On success, return a list of the values in object o. On failure, return NULL. Changed in version 3.7: Previously, the function returned a list or a tuple.
(PyMem_Free data-ptr)
Frees the memory block pointed to by p, which must have been returned by a previous call to PyMem_Malloc(), PyMem_Realloc() or PyMem_Calloc(). Otherwise, or if PyMem_Free(p) has been called before, undefined behavior occurs.
If p is NULL, no operation is performed.
Frees the memory block pointed to by p, which must have been returned by a previous call to PyMem_Malloc(), PyMem_Realloc() or PyMem_Calloc(). Otherwise, or if PyMem_Free(p) has been called before, undefined behavior occurs. If p is NULL, no operation is performed.
(PyModule_AddFunctions module functions)
Add the functions from the NULL terminated functions array to module. Refer to the PyMethodDef documentation for details on individual entries (due to the lack of a shared module namespace, module level “functions” implemented in C typically receive the module as their first parameter, making them similar to instance methods on Python classes). This function is called automatically when creating a module from PyModuleDef, using either PyModule_Create or PyModule_FromDefAndSpec.
Add the functions from the NULL terminated functions array to module. Refer to the PyMethodDef documentation for details on individual entries (due to the lack of a shared module namespace, module level “functions” implemented in C typically receive the module as their first parameter, making them similar to instance methods on Python classes). This function is called automatically when creating a module from PyModuleDef, using either PyModule_Create or PyModule_FromDefAndSpec.
(PyModule_AddIntConstant module name value)
Add an integer constant to module as name. This convenience function can be used from the module’s initialization function. Return -1 on error, 0 on success.
Add an integer constant to module as name. This convenience function can be used from the module’s initialization function. Return -1 on error, 0 on success.
(PyModule_AddObject module name value)
Add an object to module as name. This is a convenience function which can be used from the module’s initialization function. This steals a reference to value. Return -1 on error, 0 on success.
Add an object to module as name. This is a convenience function which can be used from the module’s initialization function. This steals a reference to value. Return -1 on error, 0 on success.
(PyModule_AddStringConstant module name value)
Add a string constant to module as name. This convenience function can be used from the module’s initialization function. The string value must be NULL-terminated. Return -1 on error, 0 on success.
Add a string constant to module as name. This convenience function can be used from the module’s initialization function. The string value must be NULL-terminated. Return -1 on error, 0 on success.
(PyModule_Check p)
Return true if p is a module object, or a subtype of a module object.
Return true if p is a module object, or a subtype of a module object.
(PyModule_GetDef module)
Return a pointer to the PyModuleDef struct from which the module was created, or NULL if the module wasn’t created from a definition.
Return a pointer to the PyModuleDef struct from which the module was created, or NULL if the module wasn’t created from a definition.
(PyModule_GetDict module)
Return value: Borrowed reference.
Return the dictionary object that implements module’s namespace; this object is the same as the dict attribute of the module object. If module is not a module object (or a subtype of a module object), SystemError is raised and NULL is returned.
It is recommended extensions use other PyModule_() and PyObject_() functions rather than directly manipulate a module’s dict.
Return value: Borrowed reference. Return the dictionary object that implements module’s namespace; this object is the same as the __dict__ attribute of the module object. If module is not a module object (or a subtype of a module object), SystemError is raised and NULL is returned. It is recommended extensions use other PyModule_*() and PyObject_*() functions rather than directly manipulate a module’s __dict__.
(PyModule_GetNameObject module)
Return value: New reference.
Return module’s name value. If the module does not provide one, or if it is not a string, SystemError is raised and NULL is returned.
New in version 3.3.
Return value: New reference. Return module’s __name__ value. If the module does not provide one, or if it is not a string, SystemError is raised and NULL is returned. New in version 3.3.
(PyModule_GetState module)
Return the “state” of the module, that is, a pointer to the block of memory allocated at module creation time, or NULL. See PyModuleDef.m_size.
Return the “state” of the module, that is, a pointer to the block of memory allocated at module creation time, or NULL. See PyModuleDef.m_size.
(PyModule_New name)
Return value: New reference.
Return a new module object with the name attribute set to name. The module’s name, doc, package, and loader attributes are filled in (all but name are set to None); the caller is responsible for providing a file attribute.
New in version 3.3.
Changed in version 3.4: package and loader are set to None.
Return value: New reference. Return a new module object with the __name__ attribute set to name. The module’s __name__, __doc__, __package__, and __loader__ attributes are filled in (all but __name__ are set to None); the caller is responsible for providing a __file__ attribute. New in version 3.3. Changed in version 3.4: __package__ and __loader__ are set to None.
(PyModule_SetDocString module docstring)
Set the docstring for module to docstring. This function is called automatically when creating a module from PyModuleDef, using either PyModule_Create or PyModule_FromDefAndSpec.
New in version 3.5.
Set the docstring for module to docstring. This function is called automatically when creating a module from PyModuleDef, using either PyModule_Create or PyModule_FromDefAndSpec. New in version 3.5.
(PyObject_Call callable args kwargs)
Return value: New reference.
Call a callable Python object callable, with arguments given by the tuple args, and named arguments given by the dictionary kwargs.
args must not be NULL, use an empty tuple if no arguments are needed. If no named arguments are needed, kwargs can be NULL.
Returns the result of the call on success, or NULL on failure.
This is the equivalent of the Python expression: callable(*args, **kwargs).
Return value: New reference. Call a callable Python object callable, with arguments given by the tuple args, and named arguments given by the dictionary kwargs. args must not be NULL, use an empty tuple if no arguments are needed. If no named arguments are needed, kwargs can be NULL. Returns the result of the call on success, or NULL on failure. This is the equivalent of the Python expression: callable(*args, **kwargs).
(PyObject_CallObject callable args)
Return value: New reference.
Call a callable Python object callable, with arguments given by the tuple args. If no arguments are needed, then args can be NULL.
Returns the result of the call on success, or NULL on failure.
This is the equivalent of the Python expression: callable(*args).
Return value: New reference. Call a callable Python object callable, with arguments given by the tuple args. If no arguments are needed, then args can be NULL. Returns the result of the call on success, or NULL on failure. This is the equivalent of the Python expression: callable(*args).
(PyObject_CheckBuffer obj)
Return 1 if obj supports the buffer interface otherwise 0. When 1 is returned, it doesn’t guarantee that PyObject_GetBuffer() will succeed. This function always succeeds.
Return 1 if obj supports the buffer interface otherwise 0. When 1 is returned, it doesn’t guarantee that PyObject_GetBuffer() will succeed. This function always succeeds.
(PyObject_Del op)
Releases memory allocated to an object using PyObject_New() or PyObject_NewVar(). This is normally called from the tp_dealloc handler specified in the object’s type. The fields of the object should not be accessed after this call as the memory is no longer a valid Python object.
Releases memory allocated to an object using PyObject_New() or PyObject_NewVar(). This is normally called from the tp_dealloc handler specified in the object’s type. The fields of the object should not be accessed after this call as the memory is no longer a valid Python object.
(PyObject_DelAttr pyobj attr-name)
Delete attribute named attr_name, for object o. Returns -1 on failure. This is the equivalent of the Python statement del o.attr_name.
Delete attribute named attr_name, for object o. Returns -1 on failure. This is the equivalent of the Python statement del o.attr_name.
(PyObject_DelAttrString pyobj attr-name)
Delete attribute named attr_name, for object o. Returns -1 on failure. This is the equivalent of the Python statement del o.attr_name.
Delete attribute named attr_name, for object o. Returns -1 on failure. This is the equivalent of the Python statement del o.attr_name.
(PyObject_DelItem o key)
Remove the mapping for the object key from the object o. Return -1 on failure. This is equivalent to the Python statement del o[key].
Remove the mapping for the object key from the object o. Return -1 on failure. This is equivalent to the Python statement del o[key].
(PyObject_Dir o)
Return value: New reference.
This is equivalent to the Python expression dir(o), returning a (possibly empty) list of strings appropriate for the object argument, or NULL if there was an error. If the argument is NULL, this is like the Python dir(), returning the names of the current locals; in this case, if no execution frame is active then NULL is returned but PyErr_Occurred() will return false.
Return value: New reference. This is equivalent to the Python expression dir(o), returning a (possibly empty) list of strings appropriate for the object argument, or NULL if there was an error. If the argument is NULL, this is like the Python dir(), returning the names of the current locals; in this case, if no execution frame is active then NULL is returned but PyErr_Occurred() will return false.
(PyObject_GenericGetAttr pyobj attr-name)
Return value: New reference.
Generic attribute getter function that is meant to be put into a type object’s tp_getattro slot. It looks for a descriptor in the dictionary of classes in the object’s MRO as well as an attribute in the object’s dict (if present). As outlined in Implementing Descriptors, data descriptors take preference over instance attributes, while non-data descriptors don’t. Otherwise, an AttributeError is raised.
Return value: New reference. Generic attribute getter function that is meant to be put into a type object’s tp_getattro slot. It looks for a descriptor in the dictionary of classes in the object’s MRO as well as an attribute in the object’s __dict__ (if present). As outlined in Implementing Descriptors, data descriptors take preference over instance attributes, while non-data descriptors don’t. Otherwise, an AttributeError is raised.
(PyObject_GenericGetDict pyobj context)
Return value: New reference.
A generic implementation for the getter of a dict descriptor. It creates the dictionary if necessary.
New in version 3.3.
Return value: New reference. A generic implementation for the getter of a __dict__ descriptor. It creates the dictionary if necessary. New in version 3.3.
(PyObject_GenericSetAttr pyobj attr-name v)
Generic attribute setter and deleter function that is meant to be put into a type object’s tp_setattro slot. It looks for a data descriptor in the dictionary of classes in the object’s MRO, and if found it takes preference over setting or deleting the attribute in the instance dictionary. Otherwise, the attribute is set or deleted in the object’s dict (if present). On success, 0 is returned, otherwise an AttributeError is raised and -1 is returned.
Generic attribute setter and deleter function that is meant to be put into a type object’s tp_setattro slot. It looks for a data descriptor in the dictionary of classes in the object’s MRO, and if found it takes preference over setting or deleting the attribute in the instance dictionary. Otherwise, the attribute is set or deleted in the object’s __dict__ (if present). On success, 0 is returned, otherwise an AttributeError is raised and -1 is returned.
(PyObject_GenericSetDict pyobj context)
A generic implementation for the setter of a dict descriptor. This implementation does not allow the dictionary to be deleted.
New in version 3.3.
A generic implementation for the setter of a __dict__ descriptor. This implementation does not allow the dictionary to be deleted. New in version 3.3.
(PyObject_GetAttr pyobj attr-name)
Return value: New reference.
Retrieve an attribute named attr_name from object o. Returns the attribute value on success, or NULL on failure. This is the equivalent of the Python expression o.attr_name.
Return value: New reference. Retrieve an attribute named attr_name from object o. Returns the attribute value on success, or NULL on failure. This is the equivalent of the Python expression o.attr_name.
(PyObject_GetAttrString pyobj attr-name)
Return value: New reference.
Retrieve an attribute named attr_name from object o. Returns the attribute value on success, or NULL on failure. This is the equivalent of the Python expression o.attr_name.
Return value: New reference. Retrieve an attribute named attr_name from object o. Returns the attribute value on success, or NULL on failure. This is the equivalent of the Python expression o.attr_name.
(PyObject_GetBuffer exporter view flags)
Send a request to exporter to fill in view as specified by flags. If the exporter cannot provide a buffer of the exact type, it MUST raise PyExc_BufferError, set view->obj to NULL and return -1.
On success, fill in view, set view->obj to a new reference to exporter and return 0. In the case of chained buffer providers that redirect requests to a single object, view->obj MAY refer to this object instead of exporter (See Buffer Object Structures).
Successful calls to PyObject_GetBuffer() must be paired with calls to PyBuffer_Release(), similar to malloc() and free(). Thus, after the consumer is done with the buffer, PyBuffer_Release() must be called exactly once.
Send a request to exporter to fill in view as specified by flags. If the exporter cannot provide a buffer of the exact type, it MUST raise PyExc_BufferError, set view->obj to NULL and return -1. On success, fill in view, set view->obj to a new reference to exporter and return 0. In the case of chained buffer providers that redirect requests to a single object, view->obj MAY refer to this object instead of exporter (See Buffer Object Structures). Successful calls to PyObject_GetBuffer() must be paired with calls to PyBuffer_Release(), similar to malloc() and free(). Thus, after the consumer is done with the buffer, PyBuffer_Release() must be called exactly once.
(PyObject_GetItem o key)
Return value: New reference.
Return element of o corresponding to the object key or NULL on failure. This is the equivalent of the Python expression o[key].
Return value: New reference. Return element of o corresponding to the object key or NULL on failure. This is the equivalent of the Python expression o[key].
(PyObject_GetIter o)
Return value: New reference.
This is equivalent to the Python expression iter(o). It returns a new iterator for the object argument, or the object itself if the object is already an iterator. Raises TypeError and returns NULL if the object cannot be iterated.
Return value: New reference. This is equivalent to the Python expression iter(o). It returns a new iterator for the object argument, or the object itself if the object is already an iterator. Raises TypeError and returns NULL if the object cannot be iterated.
(PyObject_HasAttr pyobj attr-name)
Returns 1 if o has the attribute attr_name, and 0 otherwise. This is equivalent to the Python expression hasattr(o, attr_name). This function always succeeds.
Note that exceptions which occur while calling getattr() and getattribute() methods will get suppressed. To get error reporting use PyObject_GetAttr() instead.
Returns 1 if o has the attribute attr_name, and 0 otherwise. This is equivalent to the Python expression hasattr(o, attr_name). This function always succeeds. Note that exceptions which occur while calling __getattr__() and __getattribute__() methods will get suppressed. To get error reporting use PyObject_GetAttr() instead.
(PyObject_HasAttrString pyobj attr-name)
Returns 1 if o has the attribute attr_name, and 0 otherwise. This is equivalent to the Python expression hasattr(o, attr_name). This function always succeeds.
Note that exceptions which occur while calling getattr() and getattribute() methods and creating a temporary string object will get suppressed. To get error reporting use Pointer_GetAttrString() instead.
Returns 1 if o has the attribute attr_name, and 0 otherwise. This is equivalent to the Python expression hasattr(o, attr_name). This function always succeeds. Note that exceptions which occur while calling __getattr__() and __getattribute__() methods and creating a temporary string object will get suppressed. To get error reporting use Pointer_GetAttrString() instead.
(PyObject_Hash o)
Compute and return the hash value of an object o. On failure, return -1. This is the equivalent of the Python expression hash(o).
Changed in version 3.2: The return type is now Py_hash_t. This is a signed integer the same size as Py_ssize_t.
Compute and return the hash value of an object o. On failure, return -1. This is the equivalent of the Python expression hash(o). Changed in version 3.2: The return type is now Py_hash_t. This is a signed integer the same size as Py_ssize_t.
(PyObject_IsTrue py-obj)
Returns 1 if the object o is considered to be true, and 0 otherwise. This is equivalent to the Python expression not not o. On failure, return -1.
Returns 1 if the object o is considered to be true, and 0 otherwise. This is equivalent to the Python expression not not o. On failure, return -1.
(PyObject_Length py-obj)
Return the length of object o. If the object o provides either the sequence and mapping protocols, the sequence length is returned. On error, -1 is returned. This is the equivalent to the Python expression len(o).
Return the length of object o. If the object o provides either the sequence and mapping protocols, the sequence length is returned. On error, -1 is returned. This is the equivalent to the Python expression len(o).
(PyObject_Not py-obj)
Returns 0 if the object o is considered to be true, and 1 otherwise. This is equivalent to the Python expression not o. On failure, return -1.
Returns 0 if the object o is considered to be true, and 1 otherwise. This is equivalent to the Python expression not o. On failure, return -1.
(PyObject_Repr py_obj)
Return value: New reference.
Compute a string representation of object o. Returns the string representation on success, NULL on failure. This is the equivalent of the Python expression repr(o). Called by the repr() built-in function.
Changed in version 3.4: This function now includes a debug assertion to help ensure that it does not silently discard an active exception.
Return value: New reference. Compute a string representation of object o. Returns the string representation on success, NULL on failure. This is the equivalent of the Python expression repr(o). Called by the repr() built-in function. Changed in version 3.4: This function now includes a debug assertion to help ensure that it does not silently discard an active exception.
(PyObject_RichCompare o1 o2 opid)
Return value: New reference.
Compare the values of o1 and o2 using the operation specified by opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or Py_GE, corresponding to <, <=, ==, !=,
, or >= respectively. This is the equivalent of the Python expression o1 op o2, where op is the operator corresponding to opid. Returns the value of the comparison on success, or NULL on failure.
Return value: New reference. Compare the values of o1 and o2 using the operation specified by opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or Py_GE, corresponding to <, <=, ==, !=, >, or >= respectively. This is the equivalent of the Python expression o1 op o2, where op is the operator corresponding to opid. Returns the value of the comparison on success, or NULL on failure.
(PyObject_RichCompareBool o1 o2 opid)
Compare the values of o1 and o2 using the operation specified by opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or Py_GE, corresponding to <, <=, ==, !=, >, or >= respectively. Returns -1 on error, 0 if the result is false, 1 otherwise. This is the equivalent of the Python expression o1 op o2, where op is the operator corresponding to opid.
Note
If o1 and o2 are the same object, PyObject_RichCompareBool() will always return 1 for Py_EQ and 0 for Py_NE.
Compare the values of o1 and o2 using the operation specified by opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or Py_GE, corresponding to <, <=, ==, !=, >, or >= respectively. Returns -1 on error, 0 if the result is false, 1 otherwise. This is the equivalent of the Python expression o1 op o2, where op is the operator corresponding to opid. Note If o1 and o2 are the same object, PyObject_RichCompareBool() will always return 1 for Py_EQ and 0 for Py_NE.
(PyObject_SetAttr pyobj attr-name v)
Set the value of the attribute named attr_name, for object o, to the value v. Raise an exception and return -1 on failure; return 0 on success. This is the equivalent of the Python statement o.attr_name = v.
If v is NULL, the attribute is deleted, however this feature is deprecated in favour of using PyObject_DelAttr().
Set the value of the attribute named attr_name, for object o, to the value v. Raise an exception and return -1 on failure; return 0 on success. This is the equivalent of the Python statement o.attr_name = v. If v is NULL, the attribute is deleted, however this feature is deprecated in favour of using PyObject_DelAttr().
(PyObject_SetAttrString pyobj attr-name v)
Set the value of the attribute named attr_name, for object o, to the value v. Raise an exception and return -1 on failure; return 0 on success. This is the equivalent of the Python statement o.attr_name = v.
If v is NULL, the attribute is deleted, however this feature is deprecated in favour of using PyObject_DelAttrString().
Set the value of the attribute named attr_name, for object o, to the value v. Raise an exception and return -1 on failure; return 0 on success. This is the equivalent of the Python statement o.attr_name = v. If v is NULL, the attribute is deleted, however this feature is deprecated in favour of using PyObject_DelAttrString().
(PyObject_SetItem o key v)
Map the object key to the value v. Raise an exception and return -1 on failure; return 0 on success. This is the equivalent of the Python statement o[key] = v.
Map the object key to the value v. Raise an exception and return -1 on failure; return 0 on success. This is the equivalent of the Python statement o[key] = v.
(PyObject_Str py-obj)
Return value: New reference.
Compute a string representation of object o. Returns the string representation on success, NULL on failure. This is the equivalent of the Python expression str(o). Called by the str() built-in function and by the print statement.
Return value: New reference. Compute a string representation of object o. Returns the string representation on success, NULL on failure. This is the equivalent of the Python expression str(o). Called by the str() built-in function and by the print statement.
(PyObject_Type py-obj)
Return value: New reference.
When o is non-NULL, returns a type object corresponding to the object type of object o. On failure, raises SystemError and returns NULL. This is equivalent to the Python expression type(o). This function increments the reference count of the return value. There’s really no reason to use this function instead of the common expression o->ob_type, which returns a pointer of type PyTypeObject*, except when the incremented reference count is needed.
Return value: New reference. When o is non-NULL, returns a type object corresponding to the object type of object o. On failure, raises SystemError and returns NULL. This is equivalent to the Python expression type(o). This function increments the reference count of the return value. There’s really no reason to use this function instead of the common expression o->ob_type, which returns a pointer of type PyTypeObject*, except when the incremented reference count is needed.
(PyRun_SimpleString command)
This is a simplified interface to PyRun_SimpleStringFlags() below, leaving the PyCompilerFlags* argument set to NULL.
This is a simplified interface to PyRun_SimpleStringFlags() below, leaving the PyCompilerFlags* argument set to NULL.
(PyRun_String program start-sym globals locals)
Return value: New reference.
Execute Python source code from str in the context specified by the objects globals and locals with the compiler flags specified by flags. globals must be a dictionary; locals can be any object that implements the mapping protocol. The parameter start specifies the start token that should be used to parse the source code.
Returns the result of executing the code as a Python object, or NULL if an exception was raised.
Return value: New reference. Execute Python source code from str in the context specified by the objects globals and locals with the compiler flags specified by flags. globals must be a dictionary; locals can be any object that implements the mapping protocol. The parameter start specifies the start token that should be used to parse the source code. Returns the result of executing the code as a Python object, or NULL if an exception was raised.
(PyRun_StringFlags program start-sym globals locals compilerflags)
Return value: New reference.
Execute Python source code from str in the context specified by the objects globals and locals with the compiler flags specified by flags. globals must be a dictionary; locals can be any object that implements the mapping protocol. The parameter start specifies the start token that should be used to parse the source code.
Returns the result of executing the code as a Python object, or NULL if an exception was raised.
Return value: New reference. Execute Python source code from str in the context specified by the objects globals and locals with the compiler flags specified by flags. globals must be a dictionary; locals can be any object that implements the mapping protocol. The parameter start specifies the start token that should be used to parse the source code. Returns the result of executing the code as a Python object, or NULL if an exception was raised.
(PySequence_Check o)
Return 1 if the object provides sequence protocol, and 0 otherwise. Note that it returns 1 for Python classes with a getitem() method unless they are dict subclasses since in general case it is impossible to determine what the type of keys it supports. This function always succeeds.
Return 1 if the object provides sequence protocol, and 0 otherwise. Note that it returns 1 for Python classes with a __getitem__() method unless they are dict subclasses since in general case it is impossible to determine what the type of keys it supports. This function always succeeds.
(PySequence_Concat o1 o2)
Return value: New reference.
Return the concatenation of o1 and o2 on success, and NULL on failure. This is the equivalent of the Python expression o1 + o2.
Return value: New reference. Return the concatenation of o1 and o2 on success, and NULL on failure. This is the equivalent of the Python expression o1 + o2.
(PySequence_Contains o value)
Determine if o contains value. If an item in o is equal to value, return 1, otherwise return 0. On error, return -1. This is equivalent to the Python expression value in o.
Determine if o contains value. If an item in o is equal to value, return 1, otherwise return 0. On error, return -1. This is equivalent to the Python expression value in o.
(PySequence_Count o value)
Return the number of occurrences of value in o, that is, return the number of keys for which o[key] == value. On failure, return -1. This is equivalent to the Python expression o.count(value).
Return the number of occurrences of value in o, that is, return the number of keys for which o[key] == value. On failure, return -1. This is equivalent to the Python expression o.count(value).
(PySequence_DelItem o i)
Delete the ith element of object o. Returns -1 on failure. This is the equivalent of the Python statement del o[i].
Delete the ith element of object o. Returns -1 on failure. This is the equivalent of the Python statement del o[i].
(PySequence_DelSlice o i1 i2)
Delete the slice in sequence object o from i1 to i2. Returns -1 on failure. This is the equivalent of the Python statement del o[i1:i2].
Delete the slice in sequence object o from i1 to i2. Returns -1 on failure. This is the equivalent of the Python statement del o[i1:i2].
(PySequence_GetItem o i)
Return value: New reference.
Return the ith element of o, or NULL on failure. This is the equivalent of the Python expression o[i].
Return value: New reference. Return the ith element of o, or NULL on failure. This is the equivalent of the Python expression o[i].
(PySequence_GetSlice o i1 i2)
Return value: New reference.
Return the slice of sequence object o between i1 and i2, or NULL on failure. This is the equivalent of the Python expression o[i1:i2].
Return value: New reference. Return the slice of sequence object o between i1 and i2, or NULL on failure. This is the equivalent of the Python expression o[i1:i2].
(PySequence_Index o value)
Return the first index i for which o[i] == value. On error, return -1. This is equivalent to the Python expression o.index(value).
Return the first index i for which o[i] == value. On error, return -1. This is equivalent to the Python expression o.index(value).
(PySequence_InPlaceConcat o1 o2)
Return value: New reference.
Return the concatenation of o1 and o2 on success, and NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python expression o1 += o2.
Return value: New reference. Return the concatenation of o1 and o2 on success, and NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python expression o1 += o2.
(PySequence_InPlaceRepeat o count)
Return value: New reference.
Return the result of repeating sequence object o count times, or NULL on failure. The operation is done in-place when o supports it. This is the equivalent of the Python expression o *= count.
Return value: New reference. Return the result of repeating sequence object o count times, or NULL on failure. The operation is done in-place when o supports it. This is the equivalent of the Python expression o *= count.
(PySequence_Length o)
Returns the number of objects in sequence o on success, and -1 on failure. This is equivalent to the Python expression len(o).
Returns the number of objects in sequence o on success, and -1 on failure. This is equivalent to the Python expression len(o).
(PySequence_List o)
Return value: New reference.
Return a list object with the same contents as the sequence or iterable o, or NULL on failure. The returned list is guaranteed to be new. This is equivalent to the Python expression list(o).
Return value: New reference. Return a list object with the same contents as the sequence or iterable o, or NULL on failure. The returned list is guaranteed to be new. This is equivalent to the Python expression list(o).
(PySequence_Repeat o count)
Return value: New reference.
Return the result of repeating sequence object o count times, or NULL on failure. This is the equivalent of the Python expression o * count.
Return value: New reference. Return the result of repeating sequence object o count times, or NULL on failure. This is the equivalent of the Python expression o * count.
(PySequence_SetItem o i v)
Assign object v to the ith element of o. Raise an exception and return -1 on failure; return 0 on success. This is the equivalent of the Python statement o[i] = v. This function does not steal a reference to v.
If v is NULL, the element is deleted, however this feature is deprecated in favour of using PySequence_DelItem().
Assign object v to the ith element of o. Raise an exception and return -1 on failure; return 0 on success. This is the equivalent of the Python statement o[i] = v. This function does not steal a reference to v. If v is NULL, the element is deleted, however this feature is deprecated in favour of using PySequence_DelItem().
(PySequence_SetSlice o i1 i2 v)
Assign the sequence object v to the slice in sequence object o from i1 to i2. This is the equivalent of the Python statement o[i1:i2] = v.
Assign the sequence object v to the slice in sequence object o from i1 to i2. This is the equivalent of the Python statement o[i1:i2] = v.
(PySequence_Tuple o)
Return value: New reference.
Return a tuple object with the same contents as the sequence or iterable o, or NULL on failure. If o is a tuple, a new reference will be returned, otherwise a tuple will be constructed with the appropriate contents. This is equivalent to the Python expression tuple(o).
Return value: New reference. Return a tuple object with the same contents as the sequence or iterable o, or NULL on failure. If o is a tuple, a new reference will be returned, otherwise a tuple will be constructed with the appropriate contents. This is equivalent to the Python expression tuple(o).
(PySet_Add set key)
Add key to a set instance. Also works with frozenset instances (like PyTuple_SetItem() it can be used to fill-in the values of brand new frozensets before they are exposed to other code). Return 0 on success or -1 on failure. Raise a TypeError if the key is unhashable. Raise a MemoryError if there is no room to grow. Raise a SystemError if set is not an instance of set or its subtype.
Add key to a set instance. Also works with frozenset instances (like PyTuple_SetItem() it can be used to fill-in the values of brand new frozensets before they are exposed to other code). Return 0 on success or -1 on failure. Raise a TypeError if the key is unhashable. Raise a MemoryError if there is no room to grow. Raise a SystemError if set is not an instance of set or its subtype.
(PySet_Check p)
Return true if p is a set object or an instance of a subtype.
Return true if p is a set object or an instance of a subtype.
(PySet_Clear set)
Empty an existing set of all elements.
Empty an existing set of all elements.
(PySet_Contains anyset key)
Return 1 if found, 0 if not found, and -1 if an error is encountered. Unlike the Python contains() method, this function does not automatically convert unhashable sets into temporary frozensets. Raise a TypeError if the key is unhashable. Raise PyExc_SystemError if anyset is not a set, frozenset, or an instance of a subtype.
Return 1 if found, 0 if not found, and -1 if an error is encountered. Unlike the Python __contains__() method, this function does not automatically convert unhashable sets into temporary frozensets. Raise a TypeError if the key is unhashable. Raise PyExc_SystemError if anyset is not a set, frozenset, or an instance of a subtype.
(PySet_Discard set key)
Return 1 if found and removed, 0 if not found (no action taken), and -1 if an error is encountered. Does not raise KeyError for missing keys. Raise a TypeError if the key is unhashable. Unlike the Python discard() method, this function does not automatically convert unhashable sets into temporary frozensets. Raise PyExc_SystemError if set is not an instance of set or its subtype.
Return 1 if found and removed, 0 if not found (no action taken), and -1 if an error is encountered. Does not raise KeyError for missing keys. Raise a TypeError if the key is unhashable. Unlike the Python discard() method, this function does not automatically convert unhashable sets into temporary frozensets. Raise PyExc_SystemError if set is not an instance of set or its subtype.
(PySet_New iterable)
Return value: New reference.
Return a new set containing objects returned by the iterable. The iterable may be NULL to create a new empty set. Return the new set on success or NULL on failure. Raise TypeError if iterable is not actually iterable. The constructor is also useful for copying a set (c=set(s)).
Return value: New reference. Return a new set containing objects returned by the iterable. The iterable may be NULL to create a new empty set. Return the new set on success or NULL on failure. Raise TypeError if iterable is not actually iterable. The constructor is also useful for copying a set (c=set(s)).
(PySet_Pop set)
Return value: New reference.
Return a new reference to an arbitrary object in the set, and removes the object from the set. Return NULL on failure. Raise KeyError if the set is empty. Raise a SystemError if set is not an instance of set or its subtype.
Return value: New reference. Return a new reference to an arbitrary object in the set, and removes the object from the set. Return NULL on failure. Raise KeyError if the set is empty. Raise a SystemError if set is not an instance of set or its subtype.
(PySys_SetArgv argc argv)
This function works like PySys_SetArgvEx() with updatepath set to 1 unless the python interpreter was started with the -I.
Use Py_DecodeLocale() to decode a bytes string to get a wchar_* string.
Changed in version 3.4: The updatepath value depends on -I.
This function works like PySys_SetArgvEx() with updatepath set to 1 unless the python interpreter was started with the -I. Use Py_DecodeLocale() to decode a bytes string to get a wchar_* string. Changed in version 3.4: The updatepath value depends on -I.
(PyThreadState_Get)
Return the current thread state. The global interpreter lock must be held. When the current thread state is NULL, this issues a fatal error (so that the caller needn’t check for NULL).
Return the current thread state. The global interpreter lock must be held. When the current thread state is NULL, this issues a fatal error (so that the caller needn’t check for NULL).
(PyThreadState_Swap tstate)
Swap the current thread state with the thread state given by the argument tstate, which may be NULL. The global interpreter lock must be held and is not released.
Swap the current thread state with the thread state given by the argument tstate, which may be NULL. The global interpreter lock must be held and is not released.
(PyTuple_Check p)
Return true if p is a tuple object or an instance of a subtype of the tuple type.
Return true if p is a tuple object or an instance of a subtype of the tuple type.
(PyTuple_GetItem p pos)
Return value: Borrowed reference.
Return the object at position pos in the tuple pointed to by p. If pos is out of bounds, return NULL and sets an IndexError exception.
Return value: Borrowed reference. Return the object at position pos in the tuple pointed to by p. If pos is out of bounds, return NULL and sets an IndexError exception.
(PyTuple_GetSlice p low high)
Return value: New reference.
Take a slice of the tuple pointed to by p from low to high and return it as a new tuple.
Return value: New reference. Take a slice of the tuple pointed to by p from low to high and return it as a new tuple.
(PyTuple_New len)
Return value: New reference.
Return a new tuple object of size len, or NULL on failure.
Return value: New reference. Return a new tuple object of size len, or NULL on failure.
(PyTuple_SetItem p pos o)
Insert a reference to object o at position pos of the tuple pointed to by p. Return 0 on success.
Note
This function “steals” a reference to o
Insert a reference to object o at position pos of the tuple pointed to by p. Return 0 on success. Note This function “steals” a reference to o
(PyType_Check o)
Return true if the object o is a type object, including instances of types derived from the standard type object. Return false in all other cases
Return true if the object o is a type object, including instances of types derived from the standard type object. Return false in all other cases
(PyType_GenericNew type args kwds)
Return value: New reference.
Generic handler for the tp_new slot of a type object. Create a new instance using the type’s tp_alloc slot.
Return value: New reference. Generic handler for the tp_new slot of a type object. Create a new instance using the type’s tp_alloc slot.
(PyType_Ready type)
Finalize a type object. This should be called on all type objects to finish their initialization. This function is responsible for adding inherited slots from a type’s base class. Return 0 on success, or return -1 and sets an exception on error.
Finalize a type object. This should be called on all type objects to finish their initialization. This function is responsible for adding inherited slots from a type’s base class. Return 0 on success, or return -1 and sets an exception on error.
(PyUnicode_AsEncodedString s encoding errors)
Return value: New reference.
Encode a Unicode object and return the result as Python bytes object. encoding and errors have the same meaning as the parameters of the same name in the Unicode encode() method. The codec to be used is looked up using the Python codec registry. Return NULL if an exception was raised by the codec. Signature: PyObject* (PyObject *unicode, const char *encoding, const char *errors)
Return value: New reference. Encode a Unicode object and return the result as Python bytes object. encoding and errors have the same meaning as the parameters of the same name in the Unicode encode() method. The codec to be used is looked up using the Python codec registry. Return NULL if an exception was raised by the codec. Signature: PyObject* (PyObject *unicode, const char *encoding, const char *errors)
(PyUnicode_AsUTF8 py-obj)
As PyUnicode_AsUTF8AndSize(), but does not store the size.
New in version 3.3.
Changed in version 3.7: The return type is now const char * rather of char *.
As PyUnicode_AsUTF8AndSize(), but does not store the size. New in version 3.3. Changed in version 3.7: The return type is now const char * rather of char *.
(PyUnicode_AsUTF8AndSize py-obj size-ptr)
Return a pointer to the UTF-8 encoding of the Unicode object, and store the size of the encoded representation (in bytes) in size. The size argument can be NULL; in this case no size will be stored. The returned buffer always has an extra null byte appended (not included in size), regardless of whether there are any other null code points.
In the case of an error, NULL is returned with an exception set and no size is stored.
This caches the UTF-8 representation of the string in the Unicode object, and subsequent calls will return a pointer to the same buffer. The caller is not responsible for deallocating the buffer.
New in version 3.3.
Changed in version 3.7: The return type is now const char * rather of char *.
Return a pointer to the UTF-8 encoding of the Unicode object, and store the size of the encoded representation (in bytes) in size. The size argument can be NULL; in this case no size will be stored. The returned buffer always has an extra null byte appended (not included in size), regardless of whether there are any other null code points. In the case of an error, NULL is returned with an exception set and no size is stored. This caches the UTF-8 representation of the string in the Unicode object, and subsequent calls will return a pointer to the same buffer. The caller is not responsible for deallocating the buffer. New in version 3.3. Changed in version 3.7: The return type is now const char * rather of char *.
(PyUnicode_Decode s size encoding errors)
Return value: New reference.
Create a Unicode object by decoding size bytes of the encoded string s. encoding and errors have the same meaning as the parameters of the same name in the str() built-in function. The codec to be used is looked up using the Python codec registry. Return NULL if an exception was raised by the codec.
Signature: PyObject* (const char *s, Py_ssize_t size, const char *encoding, const char *errors)
Return value: New reference. Create a Unicode object by decoding size bytes of the encoded string s. encoding and errors have the same meaning as the parameters of the same name in the str() built-in function. The codec to be used is looked up using the Python codec registry. Return NULL if an exception was raised by the codec. Signature: PyObject* (const char *s, Py_ssize_t size, const char *encoding, const char *errors)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close