You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.8 KiB

Merged revisions 59333-59370 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines Fix typo. ........ r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line Fixed quoting and paths in the sqlite project file ........ r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line Fixed error in regrtest. I must have missed the spot. ........ r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError ........ r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line Added msg to Misc/NEWS ........ r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line Spelling fix ........ r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines Add examples to csv, pprint and traceback docs. Written by Ross for GHOP. ........ r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line Error checking was too aggressive (reported by Chris Tismer) ........ r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines Add examples to re docs. Written for GHOP by Dan Finnie. ........ r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines Fix markup. ........ r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line Updated documentation and build_tkinter.py script ........ r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines Another markup fix. ........ r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard by purging bindings to OSA's debug API's. Those APIs we're completely unsupported on OSX 10.4 and are no longer available on OSX 10.5. Note that this patches a generated file. This is somewhat acceptable because regenerating the file is non-trivial and wouldn't use system headers anyway. ........ r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line Fixed bug #1557 by using popen.communicate() before popen.wait() ........
19 years ago
  1. .. highlightlang:: c
  2. .. _countingrefs:
  3. ******************
  4. Reference Counting
  5. ******************
  6. The macros in this section are used for managing reference counts of Python
  7. objects.
  8. .. c:function:: void Py_INCREF(PyObject *o)
  9. Increment the reference count for object *o*. The object must not be *NULL*; if
  10. you aren't sure that it isn't *NULL*, use :c:func:`Py_XINCREF`.
  11. .. c:function:: void Py_XINCREF(PyObject *o)
  12. Increment the reference count for object *o*. The object may be *NULL*, in
  13. which case the macro has no effect.
  14. .. c:function:: void Py_DECREF(PyObject *o)
  15. Decrement the reference count for object *o*. The object must not be *NULL*; if
  16. you aren't sure that it isn't *NULL*, use :c:func:`Py_XDECREF`. If the reference
  17. count reaches zero, the object's type's deallocation function (which must not be
  18. *NULL*) is invoked.
  19. .. warning::
  20. The deallocation function can cause arbitrary Python code to be invoked (e.g.
  21. when a class instance with a :meth:`__del__` method is deallocated). While
  22. exceptions in such code are not propagated, the executed code has free access to
  23. all Python global variables. This means that any object that is reachable from
  24. a global variable should be in a consistent state before :c:func:`Py_DECREF` is
  25. invoked. For example, code to delete an object from a list should copy a
  26. reference to the deleted object in a temporary variable, update the list data
  27. structure, and then call :c:func:`Py_DECREF` for the temporary variable.
  28. .. c:function:: void Py_XDECREF(PyObject *o)
  29. Decrement the reference count for object *o*. The object may be *NULL*, in
  30. which case the macro has no effect; otherwise the effect is the same as for
  31. :c:func:`Py_DECREF`, and the same warning applies.
  32. .. c:function:: void Py_CLEAR(PyObject *o)
  33. Decrement the reference count for object *o*. The object may be *NULL*, in
  34. which case the macro has no effect; otherwise the effect is the same as for
  35. :c:func:`Py_DECREF`, except that the argument is also set to *NULL*. The warning
  36. for :c:func:`Py_DECREF` does not apply with respect to the object passed because
  37. the macro carefully uses a temporary variable and sets the argument to *NULL*
  38. before decrementing its reference count.
  39. It is a good idea to use this macro whenever decrementing the value of a
  40. variable that might be traversed during garbage collection.
  41. The following functions are for runtime dynamic embedding of Python:
  42. ``Py_IncRef(PyObject *o)``, ``Py_DecRef(PyObject *o)``. They are
  43. simply exported function versions of :c:func:`Py_XINCREF` and
  44. :c:func:`Py_XDECREF`, respectively.
  45. The following functions or macros are only for use within the interpreter core:
  46. :c:func:`_Py_Dealloc`, :c:func:`_Py_ForgetReference`, :c:func:`_Py_NewReference`,
  47. as well as the global variable :c:data:`_Py_RefTotal`.