If the *converter* returns ``Py_CLEANUP_SUPPORTED``, it may get called a
second time if the argument parsing eventually fails, giving the converter a
chance to release any memory that it had already allocated. In this second
- call, the *object* parameter will be NULL; *address* will have the same value
+ call, the *object* parameter will be ``NULL``; *address* will have the same value
as in the original call.
.. versionchanged:: 3.1
.. c:member:: Py_ssize_t itemsize
Item size in bytes of a single element. Same as the value of :func:`struct.calcsize`
- called on non-NULL :c:member:`~Py_buffer.format` values.
+ called on non-``NULL`` :c:member:`~Py_buffer.format` values.
Important exception: If a consumer requests a buffer without the
:c:macro:`PyBUF_FORMAT` flag, :c:member:`~Py_buffer.format` will
memory block).
If all suboffsets are negative (i.e. no de-referencing is needed), then
- this field must be NULL (the default value).
+ this field must be ``NULL`` (the default value).
This type of array representation is used by the Python Imaging Library
(PIL). See `complex arrays`_ for further information how to access elements
Here is a function that returns a pointer to the element in an N-D array
-pointed to by an N-dimensional index when there are both non-NULL strides
+pointed to by an N-dimensional index when there are both non-``NULL`` strides
and suboffsets::
void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,
If this function is used as part of a :ref:`getbufferproc <buffer-structs>`,
*exporter* MUST be set to the exporting object and *flags* must be passed
- unmodified. Otherwise, *exporter* MUST be NULL.
+ unmodified. Otherwise, *exporter* MUST be ``NULL``.
If the platform doesn't have :c:func:`vsnprintf` and the buffer size needed to
avoid truncation exceeds *size* by more than 512 bytes, Python aborts with a
-*Py_FatalError*.
+:c:func:`Py_FatalError`.
The return value (*rv*) for these functions should be interpreted as follows:
must be 0 and is ignored. The ``'r'`` format code specifies the
standard :func:`repr` format.
- *flags* can be zero or more of the values *Py_DTSF_SIGN*,
- *Py_DTSF_ADD_DOT_0*, or *Py_DTSF_ALT*, or-ed together:
+ *flags* can be zero or more of the values ``Py_DTSF_SIGN``,
+ ``Py_DTSF_ADD_DOT_0``, or ``Py_DTSF_ALT``, or-ed together:
- * *Py_DTSF_SIGN* means to always precede the returned string with a sign
+ * ``Py_DTSF_SIGN`` means to always precede the returned string with a sign
character, even if *val* is non-negative.
- * *Py_DTSF_ADD_DOT_0* means to ensure that the returned string will not look
+ * ``Py_DTSF_ADD_DOT_0`` means to ensure that the returned string will not look
like an integer.
- * *Py_DTSF_ALT* means to apply "alternate" formatting rules. See the
+ * ``Py_DTSF_ALT`` means to apply "alternate" formatting rules. See the
documentation for the :c:func:`PyOS_snprintf` ``'#'`` specifier for
details.
- If *ptype* is non-NULL, then the value it points to will be set to one of
- *Py_DTST_FINITE*, *Py_DTST_INFINITE*, or *Py_DTST_NAN*, signifying that
+ If *ptype* is non-``NULL``, then the value it points to will be set to one of
+ ``Py_DTST_FINITE``, ``Py_DTST_INFINITE``, or ``Py_DTST_NAN``, signifying that
*val* is a finite number, an infinite number, or not a number, respectively.
The return value is a pointer to *buffer* with the converted string or
.. c:function:: int PyCoro_CheckExact(PyObject *ob)
- Return true if *ob*'s type is *PyCoro_Type*; *ob* must not be ``NULL``.
+ Return true if *ob*'s type is :c:type:`PyCoro_Type`; *ob* must not be ``NULL``.
.. c:function:: PyObject* PyCoro_New(PyFrameObject *frame, PyObject *name, PyObject *qualname)
Concretely, the error indicator consists of three object pointers: the
exception's type, the exception's value, and the traceback object. Any
-of those pointers can be NULL if non-set (although some combinations are
-forbidden, for example you can't have a non-NULL traceback if the exception
-type is NULL).
+of those pointers can be ``NULL`` if non-set (although some combinations are
+forbidden, for example you can't have a non-``NULL`` traceback if the exception
+type is ``NULL``).
When a function must fail because some function it called failed, it generally
doesn't set the error indicator; the function it called already set it. It is
These functions help you set the current thread's error indicator.
For convenience, some of these functions will always return a
-NULL pointer for use in a ``return`` statement.
+``NULL`` pointer for use in a ``return`` statement.
.. c:function:: void PyErr_SetString(PyObject *type, const char *message)
.. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname)
As :c:func:`PyFunction_New`, but also allows setting the function object's
- ``__qualname__`` attribute. *qualname* should be a unicode object or NULL;
- if NULL, the ``__qualname__`` attribute is set to the same value as its
+ ``__qualname__`` attribute. *qualname* should be a unicode object or ``NULL``;
+ if ``NULL``, the ``__qualname__`` attribute is set to the same value as its
``__name__`` attribute.
.. versionadded:: 3.3
.. c:function:: int PyFunction_SetDefaults(PyObject *op, PyObject *defaults)
Set the argument default values for the function object *op*. *defaults* must be
- *Py_None* or a tuple.
+ ``Py_None`` or a tuple.
Raises :exc:`SystemError` and returns ``-1`` on failure.
.. c:function:: int PyFunction_SetClosure(PyObject *op, PyObject *closure)
Set the closure associated with the function object *op*. *closure* must be
- *Py_None* or a tuple of cell objects.
+ ``Py_None`` or a tuple of cell objects.
Raises :exc:`SystemError` and returns ``-1`` on failure.
.. c:function:: int PyFunction_SetAnnotations(PyObject *op, PyObject *annotations)
Set the annotations for the function object *op*. *annotations*
- must be a dictionary or *Py_None*.
+ must be a dictionary or ``Py_None``.
Raises :exc:`SystemError` and returns ``-1`` on failure.
.. c:function:: int PyGen_CheckExact(PyObject *ob)
- Return true if *ob*'s type is *PyGen_Type*; *ob* must not be ``NULL``.
+ Return true if *ob*'s type is :c:type:`PyGen_Type`; *ob* must not be ``NULL``.
.. c:function:: PyObject* PyGen_New(PyFrameObject *frame)
.. c:function:: PyObject* PyImport_GetModule(PyObject *name)
Return the already imported module with the given name. If the
- module has not been imported yet then returns NULL but does not set
- an error. Returns NULL and sets an error if the lookup failed.
+ module has not been imported yet then returns ``NULL`` but does not set
+ an error. Returns ``NULL`` and sets an error if the lookup failed.
.. versionadded:: 3.7
It overrides :envvar:`PYTHONIOENCODING` values, and allows embedding code
to control IO encoding when the environment variable does not work.
- ``encoding`` and/or ``errors`` may be NULL to use
+ *encoding* and/or *errors* may be ``NULL`` to use
:envvar:`PYTHONIOENCODING` and/or default values (depending on other
settings).
The module supports two versions of the data format: version 0 is the
historical version, version 1 shares interned strings in the file, and upon
unmarshalling. Version 2 uses a binary format for floating point numbers.
-*Py_MARSHAL_VERSION* indicates the current file format (currently 2).
+``Py_MARSHAL_VERSION`` indicates the current file format (currently 2).
.. c:function:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version)
Set the memory block allocator of the specified domain.
- The new allocator must return a distinct non-NULL pointer when requesting
+ The new allocator must return a distinct non-``NULL`` pointer when requesting
zero bytes.
For the :c:data:`PYMEM_DOMAIN_RAW` domain, the allocator must be
convert to a Py_ssize_t value would raise an :exc:`OverflowError`, then the
*exc* argument is the type of exception that will be raised (usually
:exc:`IndexError` or :exc:`OverflowError`). If *exc* is ``NULL``, then the
- exception is cleared and the value is clipped to *PY_SSIZE_T_MIN* for a negative
- integer or *PY_SSIZE_T_MAX* for a positive integer.
+ exception is cleared and the value is clipped to ``PY_SSIZE_T_MIN`` for a negative
+ integer or ``PY_SSIZE_T_MAX`` for a positive integer.
.. c:function:: int PyIndex_Check(PyObject *o)
| ``name`` | ``const char *`` | name of the struct sequence type |
+-------------------+------------------------------+--------------------------------------+
| ``doc`` | ``const char *`` | pointer to docstring for the type |
- | | | or NULL to omit |
+ | | | or ``NULL`` to omit |
+-------------------+------------------------------+--------------------------------------+
| ``fields`` | ``PyStructSequence_Field *`` | pointer to ``NULL``-terminated array |
| | | with field names of the new type |
:attr:`fields` array of the :c:type:`PyStructSequence_Desc` determines which
field of the struct sequence is described.
- +-----------+------------------+----------------------------------------+
- | Field | C Type | Meaning |
- +===========+==================+========================================+
- | ``name`` | ``const char *`` | name for the field or ``NULL`` to end |
- | | | the list of named fields, set to |
- | | | PyStructSequence_UnnamedField to |
- | | | leave unnamed |
- +-----------+------------------+----------------------------------------+
- | ``doc`` | ``const char *`` | field docstring or ``NULL`` to omit |
- +-----------+------------------+----------------------------------------+
+ +-----------+------------------+-----------------------------------------+
+ | Field | C Type | Meaning |
+ +===========+==================+=========================================+
+ | ``name`` | ``const char *`` | name for the field or ``NULL`` to end |
+ | | | the list of named fields, set to |
+ | | | :c:data:`PyStructSequence_UnnamedField` |
+ | | | to leave unnamed |
+ +-----------+------------------+-----------------------------------------+
+ | ``doc`` | ``const char *`` | field docstring or ``NULL`` to omit |
+ +-----------+------------------+-----------------------------------------+
.. c:var:: char* PyStructSequence_UnnamedField
.. note::
The width formatter unit is number of characters rather than bytes.
The precision formatter unit is number of bytes for ``"%s"`` and
- ``"%V"`` (if the ``PyObject*`` argument is NULL), and a number of
+ ``"%V"`` (if the ``PyObject*`` argument is ``NULL``), and a number of
characters for ``"%A"``, ``"%U"``, ``"%S"``, ``"%R"`` and ``"%V"``
- (if the ``PyObject*`` argument is not NULL).
+ (if the ``PyObject*`` argument is not ``NULL``).
.. [1] For integer specifiers (d, u, ld, li, lu, lld, lli, llu, zd, zi,
zu, i, x): the 0-conversion flag has effect even when a precision is given.
If byteorder is ``0``, the output string will always start with the Unicode BOM
mark (U+FEFF). In the other two modes, no BOM mark is prepended.
- If *Py_UNICODE_WIDE* is not defined, surrogate pairs will be output
+ If ``Py_UNICODE_WIDE`` is not defined, surrogate pairs will be output
as a single code point.
Return ``NULL`` if an exception was raised by the codec.
If byteorder is ``0``, the output string will always start with the Unicode BOM
mark (U+FEFF). In the other two modes, no BOM mark is prepended.
- If *Py_UNICODE_WIDE* is defined, a single :c:type:`Py_UNICODE` value may get
+ If ``Py_UNICODE_WIDE`` is defined, a single :c:type:`Py_UNICODE` value may get
represented as a surrogate pair. If it is not defined, each :c:type:`Py_UNICODE`
values is interpreted as a UCS-2 character.
.. c:function:: int PyRun_SimpleString(const char *command)
This is a simplified interface to :c:func:`PyRun_SimpleStringFlags` below,
- leaving the *PyCompilerFlags\** argument set to NULL.
+ leaving the :c:type:`PyCompilerFlags`\* argument set to ``NULL``.
.. c:function:: int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
:c:func:`PyObject_CallObject`. This function has two arguments, both pointers to
arbitrary Python objects: the Python function, and the argument list. The
argument list must always be a tuple object, whose length is the number of
-arguments. To call the Python function with no arguments, pass in NULL, or
+arguments. To call the Python function with no arguments, pass in ``NULL``, or
an empty tuple; to call it with one argument, pass a singleton tuple.
:c:func:`Py_BuildValue` returns a tuple when its format string consists of zero
or more format codes between parentheses. For example::
DecodeFSDefault
None of these take parameters. For the first three, return -1 to indicate
-error. For ``DecodeFSDefault``, the return type is ``const char *``; return a NULL
+error. For ``DecodeFSDefault``, the return type is ``const char *``; return a ``NULL``
pointer to indicate an error.
(There's also an experimental ``NoneType`` converter, which lets you
epoch, and the ``GetModuleHandleA()`` function, which returns a win32 module
handle.
-This example calls both functions with a NULL pointer (``None`` should be used
-as the NULL pointer)::
+This example calls both functions with a ``NULL`` pointer (``None`` should be used
+as the ``NULL`` pointer)::
>>> print(libc.time(None)) # doctest: +SKIP
1150640792
can iterate over it, but we just have to make sure that our loop terminates,
because pointers have no size. Sooner or later it would probably crash with an
access violation or whatever, so it's better to break out of the loop when we
-hit the NULL entry::
+hit the ``NULL`` entry::
>>> for item in table:
... if item.name is None:
A list of objects which the collector found to be unreachable but could
not be freed (uncollectable objects). Starting with Python 3.4, this
list should be empty most of the time, except when using instances of
- C extension types with a non-NULL ``tp_del`` slot.
+ C extension types with a non-``NULL`` ``tp_del`` slot.
If :const:`DEBUG_SAVEALL` is set, then all unreachable objects will be
added to this list rather than freed.
``None`` or a :term:`bytes-like object` representing a buffer. In the later
case it is up to the caller to ensure that the bytestring contains the
proper bits (see the optional built-in module :mod:`struct` for a way to
- encode C structures as bytestrings). When value is set to ``None``,
- optlen argument is required. It's equivalent to call setsockopt C
- function with optval=NULL and optlen=optlen.
+ encode C structures as bytestrings). When *value* is set to ``None``,
+ *optlen* argument is required. It's equivalent to call :c:func:`setsockopt` C
+ function with ``optval=NULL`` and ``optlen=optlen``.
.. versionchanged:: 3.5
value set by the :func:`SetValue` method for the key identified by *key*.
Values in the registry have name, type, and data components. This method
- retrieves the data for a key's first value that has a NULL name. But the
+ retrieves the data for a key's first value that has a ``NULL`` name. But the
underlying API call doesn't return the type, so always use
:func:`QueryValueEx` if possible.
<https://msdn.microsoft.com/en-us/library/ms724878%28v=VS.85%29.aspx>`__
for more details.
- This function passes NULL for *security_attributes* to the API.
+ This function passes ``NULL`` for *security_attributes* to the API.
.. function:: SetValue(key, sub_key, type, value)
correctly copy bound instance methods. (Implemented by
Robert Collins; :issue:`1515`.)
-* The :mod:`ctypes` module now always converts ``None`` to a C NULL
+* The :mod:`ctypes` module now always converts ``None`` to a C ``NULL``
pointer for arguments declared as pointers. (Changed by Thomas
Heller; :issue:`4606`.) The underlying `libffi library
<https://sourceware.org/libffi/>`__ has been updated to version
* :c:func:`PyThread_set_key_value` now always set the value. In Python
3.3, the function did nothing if the key already exists (if the current
- value is a non-NULL pointer).
+ value is a non-``NULL`` pointer).
* The ``f_tstate`` (thread state) field of the :c:type:`PyFrameObject`
structure has been removed to fix a bug: see :issue:`14432` for the