@@ -208,43 +208,48 @@ recommended for best performance.
208208
209209.. _debug-build :
210210
211- Debug build
212- -----------
211+ Python Debug Build
212+ ------------------
213213
214214A debug build is Python built with the :option: `--with-pydebug ` configure
215215option.
216216
217217Effects of a debug build:
218218
219- * Define ``Py_DEBUG `` and ``Py_REF_DEBUG `` macros.
219+ * Display all warnings by default: the list of default warning filters is empty
220+ in the :mod: `warnings ` module.
220221* Add ``d `` to :data: `sys.abiflags `.
221222* Add :func: `sys.gettotalrefcount ` function.
222223* Add :option: `-X showrefcount <-X> ` command line option.
223224* Add :envvar: `PYTHONTHREADDEBUG ` environment variable.
224225* Add support for the ``__ltrace__ `` variable: enable low-level tracing in the
225226 bytecode evaluation loop if the variable is defined.
226- * The list of default warning filters is empty in the :mod: `warnings ` module.
227- * Install debug hooks on memory allocators to detect buffer overflow and other
228- memory errors: see :c:func: `PyMem_SetupDebugHooks `.
229- * Build Python with assertions (don't set ``NDEBUG `` macro):
230- ``assert(...); `` and ``_PyObject_ASSERT(...); ``.
231- See also the :option: `--with-assertions ` configure option.
232- * Unicode and int objects are created with their memory filled with a pattern
233- to help detecting uninitialized bytes.
234- * Many functions ensure that are not called with an exception raised, since
235- they can clear or replace the current exception.
236- * The garbage collector (:func: `gc.collect ` function) runs some basic checks on
237- objects consistency.
238- * More generally, add runtime checks, code surroundeded by ``#ifdef Py_DEBUG ``
239- and ``#endif ``.
227+ * Install :ref: `debug hooks on memory allocators <default-memory-allocators >`
228+ to detect buffer overflow and other memory errors.
229+ * Define ``Py_DEBUG `` and ``Py_REF_DEBUG `` macros.
230+ * Add runtime checks: code surroundeded by ``#ifdef Py_DEBUG `` and ``#endif ``.
231+ Enable ``assert(...) `` and ``_PyObject_ASSERT(...) `` assertions: don't set
232+ the ``NDEBUG `` macro (see also the :option: `--with-assertions ` configure
233+ option). Main runtime checks:
234+
235+ * Add sanity checks on the function arguments.
236+ * Unicode and int objects are created with their memory filled with a pattern
237+ to detect usage of uninitialized objects.
238+ * Ensure that functions which can clear or replace the current exception are
239+ not called with an exception raised.
240+ * The garbage collector (:func: `gc.collect ` function) runs some basic checks
241+ on objects consistency.
242+ * The :c:macro: `Py_SAFE_DOWNCAST() ` macro checks for integer underflow and
243+ overflow when downcasting from wide types to narrow types.
240244
241245See also the :ref: `Python Development Mode <devmode >` and the
242246:option: `--with-trace-refs ` configure option.
243247
244248.. versionchanged :: 3.8
245249 Release builds and debug builds are now ABI compatible: defining the
246- ``Py_DEBUG `` macro no longer implies the ``Py_TRACE_REFS `` macro, which
247- introduces the only ABI incompatibility.
250+ ``Py_DEBUG `` macro no longer implies the ``Py_TRACE_REFS `` macro (see the
251+ :option: `--with-trace-refs ` option), which introduces the only ABI
252+ incompatibility.
248253
249254
250255Debug options
0 commit comments