Commit 321976b6 authored by Georg Brandl's avatar Georg Brandl

Remove versionadded and versionchanged directives, fold information into text where necessary.

parent 2326a79d
...@@ -170,10 +170,6 @@ Object Protocol ...@@ -170,10 +170,6 @@ Object Protocol
of the value of that attribute with *cls* will be used to determine the result of the value of that attribute with *cls* will be used to determine the result
of this function. of this function.
.. versionadded:: 2.1
.. versionchanged:: 2.2
Support for a tuple as the second argument added.
Subclass determination is done in a fairly straightforward way, but includes a Subclass determination is done in a fairly straightforward way, but includes a
wrinkle that implementors of extensions to the class system may want to be aware wrinkle that implementors of extensions to the class system may want to be aware
...@@ -196,11 +192,6 @@ is considered sufficient for this determination. ...@@ -196,11 +192,6 @@ is considered sufficient for this determination.
``0``. If either *derived* or *cls* is not an actual class object (or tuple), ``0``. If either *derived* or *cls* is not an actual class object (or tuple),
this function uses the generic algorithm described above. this function uses the generic algorithm described above.
.. versionadded:: 2.1
.. versionchanged:: 2.3
Older versions of Python did not support a tuple as the second argument.
.. cfunction:: int PyCallable_Check(PyObject *o) .. cfunction:: int PyCallable_Check(PyObject *o)
...@@ -217,8 +208,6 @@ is considered sufficient for this determination. ...@@ -217,8 +208,6 @@ is considered sufficient for this determination.
success, or *NULL* on failure. This is the equivalent of the Python expression success, or *NULL* on failure. This is the equivalent of the Python expression
``callable_object(*args, **kw)``. ``callable_object(*args, **kw)``.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args) .. cfunction:: PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args)
...@@ -257,8 +246,6 @@ is considered sufficient for this determination. ...@@ -257,8 +246,6 @@ is considered sufficient for this determination.
of parameters followed by *NULL*. Returns the result of the call on success, or of parameters followed by *NULL*. Returns the result of the call on success, or
*NULL* on failure. *NULL* on failure.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL) .. cfunction:: PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)
...@@ -268,8 +255,6 @@ is considered sufficient for this determination. ...@@ -268,8 +255,6 @@ is considered sufficient for this determination.
of parameters followed by *NULL*. Returns the result of the call on success, or of parameters followed by *NULL*. Returns the result of the call on success, or
*NULL* on failure. *NULL* on failure.
.. versionadded:: 2.2
.. cfunction:: long PyObject_Hash(PyObject *o) .. cfunction:: long PyObject_Hash(PyObject *o)
...@@ -311,8 +296,6 @@ is considered sufficient for this determination. ...@@ -311,8 +296,6 @@ is considered sufficient for this determination.
Return true if the object *o* is of type *type* or a subtype of *type*. Both Return true if the object *o* is of type *type* or a subtype of *type*. Both
parameters must be non-*NULL*. parameters must be non-*NULL*.
.. versionadded:: 2.2
.. cfunction:: Py_ssize_t PyObject_Length(PyObject *o) .. cfunction:: Py_ssize_t PyObject_Length(PyObject *o)
Py_ssize_t PyObject_Size(PyObject *o) Py_ssize_t PyObject_Size(PyObject *o)
...@@ -408,8 +391,6 @@ Number Protocol ...@@ -408,8 +391,6 @@ Number Protocol
Return the floor of *o1* divided by *o2*, or *NULL* on failure. This is Return the floor of *o1* divided by *o2*, or *NULL* on failure. This is
equivalent to the "classic" division of integers. equivalent to the "classic" division of integers.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2) .. cfunction:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
...@@ -419,8 +400,6 @@ Number Protocol ...@@ -419,8 +400,6 @@ Number Protocol
numbers in base two. This function can return a floating point value when numbers in base two. This function can return a floating point value when
passed two integers. passed two integers.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2) .. cfunction:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)
...@@ -536,8 +515,6 @@ Number Protocol ...@@ -536,8 +515,6 @@ Number Protocol
The operation is done *in-place* when *o1* supports it. This is the equivalent The operation is done *in-place* when *o1* supports it. This is the equivalent
of the Python statement ``o1 //= o2``. of the Python statement ``o1 //= o2``.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2) .. cfunction:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2)
...@@ -547,8 +524,6 @@ Number Protocol ...@@ -547,8 +524,6 @@ Number Protocol
numbers in base two. This function can return a floating point value when numbers in base two. This function can return a floating point value when
passed two integers. The operation is done *in-place* when *o1* supports it. passed two integers. The operation is done *in-place* when *o1* supports it.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2) .. cfunction:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)
...@@ -633,8 +608,6 @@ Number Protocol ...@@ -633,8 +608,6 @@ Number Protocol
Returns the *o* converted to a Python int or long on success or *NULL* with a Returns the *o* converted to a Python int or long on success or *NULL* with a
TypeError exception raised on failure. TypeError exception raised on failure.
.. versionadded:: 2.5
.. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc) .. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
...@@ -646,16 +619,12 @@ Number Protocol ...@@ -646,16 +619,12 @@ Number Protocol
exception is cleared and the value is clipped to *PY_SSIZE_T_MIN* for a negative 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. integer or *PY_SSIZE_T_MAX* for a positive integer.
.. versionadded:: 2.5
.. cfunction:: int PyIndex_Check(PyObject *o) .. cfunction:: int PyIndex_Check(PyObject *o)
Returns True if *o* is an index integer (has the nb_index slot of the Returns True if *o* is an index integer (has the nb_index slot of the
tp_as_number structure filled in). tp_as_number structure filled in).
.. versionadded:: 2.5
.. _sequence: .. _sequence:
...@@ -801,8 +770,6 @@ Sequence Protocol ...@@ -801,8 +770,6 @@ Sequence Protocol
Return the underlying array of PyObject pointers. Assumes that *o* was returned Return the underlying array of PyObject pointers. Assumes that *o* was returned
by :cfunc:`PySequence_Fast` and *o* is not *NULL*. by :cfunc:`PySequence_Fast` and *o* is not *NULL*.
.. versionadded:: 2.4
.. cfunction:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i) .. cfunction:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i)
...@@ -811,8 +778,6 @@ Sequence Protocol ...@@ -811,8 +778,6 @@ Sequence Protocol
:cfunc:`PySequence_Check(o)` is true and without adjustment for negative :cfunc:`PySequence_Check(o)` is true and without adjustment for negative
indices. indices.
.. versionadded:: 2.3
.. cfunction:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o) .. cfunction:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o)
...@@ -906,11 +871,8 @@ Mapping Protocol ...@@ -906,11 +871,8 @@ Mapping Protocol
Iterator Protocol Iterator Protocol
================= =================
.. versionadded:: 2.2
There are only a couple of functions specifically for working with iterators. There are only a couple of functions specifically for working with iterators.
.. cfunction:: int PyIter_Check(PyObject *o) .. cfunction:: int PyIter_Check(PyObject *o)
Return true if the object *o* supports the iterator protocol. Return true if the object *o* supports the iterator protocol.
...@@ -965,8 +927,6 @@ Buffer Protocol ...@@ -965,8 +927,6 @@ Buffer Protocol
*buffer_len* to the buffer length. Returns ``-1`` and sets a :exc:`TypeError` *buffer_len* to the buffer length. Returns ``-1`` and sets a :exc:`TypeError`
on error. on error.
.. versionadded:: 1.6
.. cfunction:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len) .. cfunction:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)
...@@ -975,16 +935,12 @@ Buffer Protocol ...@@ -975,16 +935,12 @@ Buffer Protocol
success, returns ``0``, sets *buffer* to the memory location and *buffer_len* to success, returns ``0``, sets *buffer* to the memory location and *buffer_len* to
the buffer length. Returns ``-1`` and sets a :exc:`TypeError` on error. the buffer length. Returns ``-1`` and sets a :exc:`TypeError` on error.
.. versionadded:: 1.6
.. cfunction:: int PyObject_CheckReadBuffer(PyObject *o) .. cfunction:: int PyObject_CheckReadBuffer(PyObject *o)
Returns ``1`` if *o* supports the single-segment readable buffer interface. Returns ``1`` if *o* supports the single-segment readable buffer interface.
Otherwise returns ``0``. Otherwise returns ``0``.
.. versionadded:: 2.2
.. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len) .. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)
...@@ -993,5 +949,3 @@ Buffer Protocol ...@@ -993,5 +949,3 @@ Buffer Protocol
``0``, sets *buffer* to the memory location and *buffer_len* to the buffer ``0``, sets *buffer* to the memory location and *buffer_len* to the buffer
length. Returns ``-1`` and sets a :exc:`TypeError` on error. length. Returns ``-1`` and sets a :exc:`TypeError` on error.
.. versionadded:: 1.6
...@@ -62,8 +62,6 @@ Type Objects ...@@ -62,8 +62,6 @@ Type Objects
Return true if the object *o* is a type object, but not a subtype of the Return true if the object *o* is a type object, but not a subtype of the
standard type object. Return false in all other cases. standard type object. Return false in all other cases.
.. versionadded:: 2.2
.. cfunction:: int PyType_HasFeature(PyObject *o, int feature) .. cfunction:: int PyType_HasFeature(PyObject *o, int feature)
...@@ -76,24 +74,20 @@ Type Objects ...@@ -76,24 +74,20 @@ Type Objects
Return true if the type object includes support for the cycle detector; this Return true if the type object includes support for the cycle detector; this
tests the type flag :const:`Py_TPFLAGS_HAVE_GC`. tests the type flag :const:`Py_TPFLAGS_HAVE_GC`.
.. versionadded:: 2.0
.. cfunction:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b) .. cfunction:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
Return true if *a* is a subtype of *b*. Return true if *a* is a subtype of *b*.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems) .. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
.. versionadded:: 2.2 XXX: Document.
.. cfunction:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds) .. cfunction:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
.. versionadded:: 2.2 XXX: Document.
.. cfunction:: int PyType_Ready(PyTypeObject *type) .. cfunction:: int PyType_Ready(PyTypeObject *type)
...@@ -103,8 +97,6 @@ Type Objects ...@@ -103,8 +97,6 @@ Type Objects
from a type's base class. Return ``0`` on success, or return ``-1`` and sets an from a type's base class. Return ``0`` on success, or return ``-1`` and sets an
exception on error. exception on error.
.. versionadded:: 2.2
.. _noneobject: .. _noneobject:
...@@ -128,9 +120,8 @@ same reason. ...@@ -128,9 +120,8 @@ same reason.
.. cmacro:: Py_RETURN_NONE .. cmacro:: Py_RETURN_NONE
Properly handle returning :cdata:`Py_None` from within a C function. Properly handle returning :cdata:`Py_None` from within a C function (that is,
increment the reference count of None and return it.)
.. versionadded:: 2.4
.. _numericobjects: .. _numericobjects:
...@@ -167,17 +158,12 @@ Plain Integer Objects ...@@ -167,17 +158,12 @@ Plain Integer Objects
Return true if *o* is of type :cdata:`PyInt_Type` or a subtype of Return true if *o* is of type :cdata:`PyInt_Type` or a subtype of
:cdata:`PyInt_Type`. :cdata:`PyInt_Type`.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyInt_CheckExact(PyObject *o) .. cfunction:: int PyInt_CheckExact(PyObject *o)
Return true if *o* is of type :cdata:`PyInt_Type`, but not a subtype of Return true if *o* is of type :cdata:`PyInt_Type`, but not a subtype of
:cdata:`PyInt_Type`. :cdata:`PyInt_Type`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyInt_FromString(char *str, char **pend, int base) .. cfunction:: PyObject* PyInt_FromString(char *str, char **pend, int base)
...@@ -212,8 +198,6 @@ Plain Integer Objects ...@@ -212,8 +198,6 @@ Plain Integer Objects
Create a new integer object with a value of *ival*. If the value exceeds Create a new integer object with a value of *ival*. If the value exceeds
``LONG_MAX``, a long integer object is returned. ``LONG_MAX``, a long integer object is returned.
.. versionadded:: 2.5
.. cfunction:: long PyInt_AsLong(PyObject *io) .. cfunction:: long PyInt_AsLong(PyObject *io)
...@@ -234,8 +218,6 @@ Plain Integer Objects ...@@ -234,8 +218,6 @@ Plain Integer Objects
:ctype:`PyLongObject`, if it is not already one, and then return its value as :ctype:`PyLongObject`, if it is not already one, and then return its value as
unsigned long. This function does not check for overflow. unsigned long. This function does not check for overflow.
.. versionadded:: 2.3
.. cfunction:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io) .. cfunction:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io)
...@@ -243,8 +225,6 @@ Plain Integer Objects ...@@ -243,8 +225,6 @@ Plain Integer Objects
:ctype:`PyLongObject`, if it is not already one, and then return its value as :ctype:`PyLongObject`, if it is not already one, and then return its value as
unsigned long long, without checking for overflow. unsigned long long, without checking for overflow.
.. versionadded:: 2.3
.. cfunction:: Py_ssize_t PyInt_AsSsize_t(PyObject *io) .. cfunction:: Py_ssize_t PyInt_AsSsize_t(PyObject *io)
...@@ -252,8 +232,6 @@ Plain Integer Objects ...@@ -252,8 +232,6 @@ Plain Integer Objects
:ctype:`PyLongObject`, if it is not already one, and then return its value as :ctype:`PyLongObject`, if it is not already one, and then return its value as
:ctype:`Py_ssize_t`. :ctype:`Py_ssize_t`.
.. versionadded:: 2.5
.. cfunction:: long PyInt_GetMax() .. cfunction:: long PyInt_GetMax()
...@@ -278,8 +256,6 @@ are available, however. ...@@ -278,8 +256,6 @@ are available, however.
Return true if *o* is of type :cdata:`PyBool_Type`. Return true if *o* is of type :cdata:`PyBool_Type`.
.. versionadded:: 2.3
.. cvar:: PyObject* Py_False .. cvar:: PyObject* Py_False
...@@ -298,24 +274,18 @@ are available, however. ...@@ -298,24 +274,18 @@ are available, however.
Return :const:`Py_False` from a function, properly incrementing its reference Return :const:`Py_False` from a function, properly incrementing its reference
count. count.
.. versionadded:: 2.4
.. cmacro:: Py_RETURN_TRUE .. cmacro:: Py_RETURN_TRUE
Return :const:`Py_True` from a function, properly incrementing its reference Return :const:`Py_True` from a function, properly incrementing its reference
count. count.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyBool_FromLong(long v) .. cfunction:: PyObject* PyBool_FromLong(long v)
Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
truth value of *v*. truth value of *v*.
.. versionadded:: 2.3
.. _longobjects: .. _longobjects:
...@@ -343,17 +313,12 @@ Long Integer Objects ...@@ -343,17 +313,12 @@ Long Integer Objects
Return true if its argument is a :ctype:`PyLongObject` or a subtype of Return true if its argument is a :ctype:`PyLongObject` or a subtype of
:ctype:`PyLongObject`. :ctype:`PyLongObject`.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyLong_CheckExact(PyObject *p) .. cfunction:: int PyLong_CheckExact(PyObject *p)
Return true if its argument is a :ctype:`PyLongObject`, but not a subtype of Return true if its argument is a :ctype:`PyLongObject`, but not a subtype of
:ctype:`PyLongObject`. :ctype:`PyLongObject`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyLong_FromLong(long v) .. cfunction:: PyObject* PyLong_FromLong(long v)
...@@ -405,17 +370,11 @@ Long Integer Objects ...@@ -405,17 +370,11 @@ Long Integer Objects
radix must be in the range [2, 36]; if it is out of range, :exc:`ValueError` radix must be in the range [2, 36]; if it is out of range, :exc:`ValueError`
will be raised. will be raised.
.. versionadded:: 1.6
.. cfunction:: PyObject* PyLong_FromVoidPtr(void *p) .. cfunction:: PyObject* PyLong_FromVoidPtr(void *p)
Create a Python integer or long integer from the pointer *p*. The pointer value Create a Python integer or long integer from the pointer *p*. The pointer value
can be retrieved from the resulting value using :cfunc:`PyLong_AsVoidPtr`. can be retrieved from the resulting value using :cfunc:`PyLong_AsVoidPtr`.
.. versionadded:: 1.5.2
.. versionchanged:: 2.5
If the integer is larger than LONG_MAX, a positive long integer is returned. If the integer is larger than LONG_MAX, a positive long integer is returned.
...@@ -445,8 +404,6 @@ Long Integer Objects ...@@ -445,8 +404,6 @@ Long Integer Objects
Return a C :ctype:`long long` from a Python long integer. If *pylong* cannot be Return a C :ctype:`long long` from a Python long integer. If *pylong* cannot be
represented as a :ctype:`long long`, an :exc:`OverflowError` will be raised. represented as a :ctype:`long long`, an :exc:`OverflowError` will be raised.
.. versionadded:: 2.2
.. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong) .. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
...@@ -455,24 +412,18 @@ Long Integer Objects ...@@ -455,24 +412,18 @@ Long Integer Objects
will be raised if the value is positive, or a :exc:`TypeError` will be raised if will be raised if the value is positive, or a :exc:`TypeError` will be raised if
the value is negative. the value is negative.
.. versionadded:: 2.2
.. cfunction:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io) .. cfunction:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io)
Return a C :ctype:`unsigned long` from a Python long integer, without checking Return a C :ctype:`unsigned long` from a Python long integer, without checking
for overflow. for overflow.
.. versionadded:: 2.3
.. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io) .. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io)
Return a C :ctype:`unsigned long long` from a Python long integer, without Return a C :ctype:`unsigned long long` from a Python long integer, without
checking for overflow. checking for overflow.
.. versionadded:: 2.3
.. cfunction:: double PyLong_AsDouble(PyObject *pylong) .. cfunction:: double PyLong_AsDouble(PyObject *pylong)
...@@ -488,9 +439,6 @@ Long Integer Objects ...@@ -488,9 +439,6 @@ Long Integer Objects
is only assured to produce a usable :ctype:`void` pointer for values created is only assured to produce a usable :ctype:`void` pointer for values created
with :cfunc:`PyLong_FromVoidPtr`. with :cfunc:`PyLong_FromVoidPtr`.
.. versionadded:: 1.5.2
.. versionchanged:: 2.5
For values outside 0..LONG_MAX, both signed and unsigned integers are acccepted. For values outside 0..LONG_MAX, both signed and unsigned integers are acccepted.
...@@ -520,17 +468,12 @@ Floating Point Objects ...@@ -520,17 +468,12 @@ Floating Point Objects
Return true if its argument is a :ctype:`PyFloatObject` or a subtype of Return true if its argument is a :ctype:`PyFloatObject` or a subtype of
:ctype:`PyFloatObject`. :ctype:`PyFloatObject`.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyFloat_CheckExact(PyObject *p) .. cfunction:: int PyFloat_CheckExact(PyObject *p)
Return true if its argument is a :ctype:`PyFloatObject`, but not a subtype of Return true if its argument is a :ctype:`PyFloatObject`, but not a subtype of
:ctype:`PyFloatObject`. :ctype:`PyFloatObject`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyFloat_FromString(PyObject *str) .. cfunction:: PyObject* PyFloat_FromString(PyObject *str)
...@@ -646,17 +589,12 @@ Complex Numbers as Python Objects ...@@ -646,17 +589,12 @@ Complex Numbers as Python Objects
Return true if its argument is a :ctype:`PyComplexObject` or a subtype of Return true if its argument is a :ctype:`PyComplexObject` or a subtype of
:ctype:`PyComplexObject`. :ctype:`PyComplexObject`.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyComplex_CheckExact(PyObject *p) .. cfunction:: int PyComplex_CheckExact(PyObject *p)
Return true if its argument is a :ctype:`PyComplexObject`, but not a subtype of Return true if its argument is a :ctype:`PyComplexObject`, but not a subtype of
:ctype:`PyComplexObject`. :ctype:`PyComplexObject`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyComplex_FromCComplex(Py_complex v) .. cfunction:: PyObject* PyComplex_FromCComplex(Py_complex v)
...@@ -682,7 +620,6 @@ Complex Numbers as Python Objects ...@@ -682,7 +620,6 @@ Complex Numbers as Python Objects
Return the :ctype:`Py_complex` value of the complex number *op*. Return the :ctype:`Py_complex` value of the complex number *op*.
.. versionchanged:: 2.6
If *op* is not a Python complex number object but has a :meth:`__complex__` If *op* is not a Python complex number object but has a :meth:`__complex__`
method, this method will first be called to convert *op* to a Python complex method, this method will first be called to convert *op* to a Python complex
number object. number object.
...@@ -729,17 +666,12 @@ called with a non-string parameter. ...@@ -729,17 +666,12 @@ called with a non-string parameter.
Return true if the object *o* is a string object or an instance of a subtype of Return true if the object *o* is a string object or an instance of a subtype of
the string type. the string type.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyString_CheckExact(PyObject *o) .. cfunction:: int PyString_CheckExact(PyObject *o)
Return true if the object *o* is a string object, but not an instance of a Return true if the object *o* is a string object, but not an instance of a
subtype of the string type. subtype of the string type.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyString_FromString(const char *v) .. cfunction:: PyObject* PyString_FromString(const char *v)
...@@ -763,9 +695,9 @@ called with a non-string parameter. ...@@ -763,9 +695,9 @@ called with a non-string parameter.
must correspond exactly to the format characters in the *format* string. The must correspond exactly to the format characters in the *format* string. The
following format characters are allowed: following format characters are allowed:
.. % This should be exactly the same as the table in PyErr_Format. .. % XXX: This should be exactly the same as the table in PyErr_Format.
.. % One should just refer to the other. .. % One should just refer to the other.
.. % The descriptions for %zd and %zu are wrong, but the truth is complicated .. % XXX: The descriptions for %zd and %zu are wrong, but the truth is complicated
.. % because not all compilers support the %z width modifier -- we fake it .. % because not all compilers support the %z width modifier -- we fake it
.. % when necessary via interpolating PY_FORMAT_SIZE_T. .. % when necessary via interpolating PY_FORMAT_SIZE_T.
.. % %u, %lu, %zu should have "new in Python 2.5" blurbs. .. % %u, %lu, %zu should have "new in Python 2.5" blurbs.
...@@ -1011,17 +943,12 @@ access internal read-only data of Unicode objects: ...@@ -1011,17 +943,12 @@ access internal read-only data of Unicode objects:
Return true if the object *o* is a Unicode object or an instance of a Unicode Return true if the object *o* is a Unicode object or an instance of a Unicode
subtype. subtype.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyUnicode_CheckExact(PyObject *o) .. cfunction:: int PyUnicode_CheckExact(PyObject *o)
Return true if the object *o* is a Unicode object, but not an instance of a Return true if the object *o* is a Unicode object, but not an instance of a
subtype. subtype.
.. versionadded:: 2.2
.. cfunction:: Py_ssize_t PyUnicode_GET_SIZE(PyObject *o) .. cfunction:: Py_ssize_t PyUnicode_GET_SIZE(PyObject *o)
...@@ -1162,16 +1089,12 @@ APIs: ...@@ -1162,16 +1089,12 @@ APIs:
*NULL*, the return value might be a shared object. Therefore, modification of *NULL*, the return value might be a shared object. Therefore, modification of
the resulting Unicode object is only allowed when *u* is *NULL*. the resulting Unicode object is only allowed when *u* is *NULL*.
.. versionadded:: 3.0
.. cfunction:: PyObject *PyUnicode_FromString(const char *u) .. cfunction:: PyObject *PyUnicode_FromString(const char *u)
Create a Unicode object from an UTF-8 encoded null-terminated char buffer Create a Unicode object from an UTF-8 encoded null-terminated char buffer
*u*. *u*.
.. versionadded:: 3.0
.. cfunction:: PyObject* PyUnicode_FromFormat(const char *format, ...) .. cfunction:: PyObject* PyUnicode_FromFormat(const char *format, ...)
...@@ -1247,16 +1170,12 @@ APIs: ...@@ -1247,16 +1170,12 @@ APIs:
An unrecognized format character causes all the rest of the format string to be An unrecognized format character causes all the rest of the format string to be
copied as-is to the result string, and any extra arguments discarded. copied as-is to the result string, and any extra arguments discarded.
.. versionadded:: 3.0
.. cfunction:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs) .. cfunction:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)
Identical to :func:`PyUnicode_FromFormat` except that it takes exactly two Identical to :func:`PyUnicode_FromFormat` except that it takes exactly two
arguments. arguments.
.. versionadded:: 3.0
.. cfunction:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode) .. cfunction:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode)
...@@ -1390,8 +1309,6 @@ These are the UTF-8 codec APIs: ...@@ -1390,8 +1309,6 @@ These are the UTF-8 codec APIs:
treated as an error. Those bytes will not be decoded and the number of bytes treated as an error. Those bytes will not be decoded and the number of bytes
that have been decoded will be stored in *consumed*. that have been decoded will be stored in *consumed*.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors) .. cfunction:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
...@@ -1434,8 +1351,6 @@ These are the UTF-32 codec APIs: ...@@ -1434,8 +1351,6 @@ These are the UTF-32 codec APIs:
Return *NULL* if an exception was raised by the codec. Return *NULL* if an exception was raised by the codec.
.. versionadded:: 2.6
.. cfunction:: PyObject* PyUnicode_DecodeUTF32Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed) .. cfunction:: PyObject* PyUnicode_DecodeUTF32Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
...@@ -1445,8 +1360,6 @@ These are the UTF-32 codec APIs: ...@@ -1445,8 +1360,6 @@ These are the UTF-32 codec APIs:
by four) as an error. Those bytes will not be decoded and the number of bytes by four) as an error. Those bytes will not be decoded and the number of bytes
that have been decoded will be stored in *consumed*. that have been decoded will be stored in *consumed*.
.. versionadded:: 2.6
.. cfunction:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) .. cfunction:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
...@@ -1466,8 +1379,6 @@ These are the UTF-32 codec APIs: ...@@ -1466,8 +1379,6 @@ These are the UTF-32 codec APIs:
Return *NULL* if an exception was raised by the codec. Return *NULL* if an exception was raised by the codec.
.. versionadded:: 2.6
.. cfunction:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode) .. cfunction:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode)
...@@ -1475,8 +1386,6 @@ These are the UTF-32 codec APIs: ...@@ -1475,8 +1386,6 @@ These are the UTF-32 codec APIs:
string always starts with a BOM mark. Error handling is "strict". Return string always starts with a BOM mark. Error handling is "strict". Return
*NULL* if an exception was raised by the codec. *NULL* if an exception was raised by the codec.
.. versionadded:: 2.6
These are the UTF-16 codec APIs: These are the UTF-16 codec APIs:
...@@ -1514,8 +1423,6 @@ These are the UTF-16 codec APIs: ...@@ -1514,8 +1423,6 @@ These are the UTF-16 codec APIs:
split surrogate pair) as an error. Those bytes will not be decoded and the split surrogate pair) as an error. Those bytes will not be decoded and the
number of bytes that have been decoded will be stored in *consumed*. number of bytes that have been decoded will be stored in *consumed*.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) .. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
...@@ -1674,9 +1581,6 @@ characters to different code points. ...@@ -1674,9 +1581,6 @@ characters to different code points.
Byte values greater that the length of the string and U+FFFE "characters" are Byte values greater that the length of the string and U+FFFE "characters" are
treated as "undefined mapping". treated as "undefined mapping".
.. versionchanged:: 2.4
Allowed unicode string as mapping argument.
.. cfunction:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors) .. cfunction:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors)
...@@ -1728,8 +1632,6 @@ the user settings on the machine running the codec. ...@@ -1728,8 +1632,6 @@ the user settings on the machine running the codec.
trailing lead byte and the number of bytes that have been decoded will be stored trailing lead byte and the number of bytes that have been decoded will be stored
in *consumed*. in *consumed*.
.. versionadded:: 2.5
.. cfunction:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors) .. cfunction:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
...@@ -2032,17 +1934,12 @@ Tuple Objects ...@@ -2032,17 +1934,12 @@ Tuple Objects
Return true if *p* is a tuple object or an instance of a subtype of the tuple Return true if *p* is a tuple object or an instance of a subtype of the tuple
type. type.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyTuple_CheckExact(PyObject *p) .. cfunction:: int PyTuple_CheckExact(PyObject *p)
Return true if *p* is a tuple object, but not an instance of a subtype of the Return true if *p* is a tuple object, but not an instance of a subtype of the
tuple type. tuple type.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyTuple_New(Py_ssize_t len) .. cfunction:: PyObject* PyTuple_New(Py_ssize_t len)
...@@ -2055,8 +1952,6 @@ Tuple Objects ...@@ -2055,8 +1952,6 @@ Tuple Objects
are initialized to the subsequent *n* C arguments pointing to Python objects. are initialized to the subsequent *n* C arguments pointing to Python objects.
``PyTuple_Pack(2, a, b)`` is equivalent to ``Py_BuildValue("(OO)", a, b)``. ``PyTuple_Pack(2, a, b)`` is equivalent to ``Py_BuildValue("(OO)", a, b)``.
.. versionadded:: 2.4
.. cfunction:: int PyTuple_Size(PyObject *p) .. cfunction:: int PyTuple_Size(PyObject *p)
...@@ -2119,9 +2014,6 @@ Tuple Objects ...@@ -2119,9 +2014,6 @@ Tuple Objects
``*p`` is destroyed. On failure, returns ``-1`` and sets ``*p`` to *NULL*, and ``*p`` is destroyed. On failure, returns ``-1`` and sets ``*p`` to *NULL*, and
raises :exc:`MemoryError` or :exc:`SystemError`. raises :exc:`MemoryError` or :exc:`SystemError`.
.. versionchanged:: 2.2
Removed unused third parameter, *last_is_sticky*.
.. _listobjects: .. _listobjects:
...@@ -2149,17 +2041,12 @@ List Objects ...@@ -2149,17 +2041,12 @@ List Objects
Return true if *p* is a list object or an instance of a subtype of the list Return true if *p* is a list object or an instance of a subtype of the list
type. type.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyList_CheckExact(PyObject *p) .. cfunction:: int PyList_CheckExact(PyObject *p)
Return true if *p* is a list object, but not an instance of a subtype of the Return true if *p* is a list object, but not an instance of a subtype of the
list type. list type.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyList_New(Py_ssize_t len) .. cfunction:: PyObject* PyList_New(Py_ssize_t len)
...@@ -2306,17 +2193,12 @@ Dictionary Objects ...@@ -2306,17 +2193,12 @@ Dictionary Objects
Return true if *p* is a dict object or an instance of a subtype of the dict Return true if *p* is a dict object or an instance of a subtype of the dict
type. type.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyDict_CheckExact(PyObject *p) .. cfunction:: int PyDict_CheckExact(PyObject *p)
Return true if *p* is a dict object, but not an instance of a subtype of the Return true if *p* is a dict object, but not an instance of a subtype of the
dict type. dict type.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyDict_New() .. cfunction:: PyObject* PyDict_New()
...@@ -2329,8 +2211,6 @@ Dictionary Objects ...@@ -2329,8 +2211,6 @@ Dictionary Objects
normally used to create a proxy to prevent modification of the dictionary for normally used to create a proxy to prevent modification of the dictionary for
non-dynamic class types. non-dynamic class types.
.. versionadded:: 2.2
.. cfunction:: void PyDict_Clear(PyObject *p) .. cfunction:: void PyDict_Clear(PyObject *p)
...@@ -2343,15 +2223,11 @@ Dictionary Objects ...@@ -2343,15 +2223,11 @@ Dictionary Objects
return ``1``, otherwise return ``0``. On error, return ``-1``. This is return ``1``, otherwise return ``0``. On error, return ``-1``. This is
equivalent to the Python expression ``key in p``. equivalent to the Python expression ``key in p``.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyDict_Copy(PyObject *p) .. cfunction:: PyObject* PyDict_Copy(PyObject *p)
Return a new dictionary that contains the same key-value pairs as *p*. Return a new dictionary that contains the same key-value pairs as *p*.
.. versionadded:: 1.6
.. cfunction:: int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val) .. cfunction:: int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)
...@@ -2471,16 +2347,12 @@ Dictionary Objects ...@@ -2471,16 +2347,12 @@ Dictionary Objects
if there is not a matching key in *a*. Return ``0`` on success or ``-1`` if an if there is not a matching key in *a*. Return ``0`` on success or ``-1`` if an
exception was raised. exception was raised.
.. versionadded:: 2.2
.. cfunction:: int PyDict_Update(PyObject *a, PyObject *b) .. cfunction:: int PyDict_Update(PyObject *a, PyObject *b)
This is the same as ``PyDict_Merge(a, b, 1)`` in C, or ``a.update(b)`` in This is the same as ``PyDict_Merge(a, b, 1)`` in C, or ``a.update(b)`` in
Python. Return ``0`` on success or ``-1`` if an exception was raised. Python. Return ``0`` on success or ``-1`` if an exception was raised.
.. versionadded:: 2.2
.. cfunction:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override) .. cfunction:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override)
...@@ -2495,8 +2367,6 @@ Dictionary Objects ...@@ -2495,8 +2367,6 @@ Dictionary Objects
if override or key not in a: if override or key not in a:
a[key] = value a[key] = value
.. versionadded:: 2.2
.. _otherobjects: .. _otherobjects:
...@@ -2533,17 +2403,12 @@ change in future releases of Python. ...@@ -2533,17 +2403,12 @@ change in future releases of Python.
Return true if its argument is a :ctype:`PyFileObject` or a subtype of Return true if its argument is a :ctype:`PyFileObject` or a subtype of
:ctype:`PyFileObject`. :ctype:`PyFileObject`.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyFile_CheckExact(PyObject *p) .. cfunction:: int PyFile_CheckExact(PyObject *p)
Return true if its argument is a :ctype:`PyFileObject`, but not a subtype of Return true if its argument is a :ctype:`PyFileObject`, but not a subtype of
:ctype:`PyFileObject`. :ctype:`PyFileObject`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyFile_FromString(char *filename, char *mode) .. cfunction:: PyObject* PyFile_FromString(char *filename, char *mode)
...@@ -2598,8 +2463,6 @@ change in future releases of Python. ...@@ -2598,8 +2463,6 @@ change in future releases of Python.
Set the file's encoding for Unicode output to *enc*. Return 1 on success and 0 Set the file's encoding for Unicode output to *enc*. Return 1 on success and 0
on failure. on failure.
.. versionadded:: 2.3
.. cfunction:: int PyFile_SoftSpace(PyObject *p, int newflag) .. cfunction:: int PyFile_SoftSpace(PyObject *p, int newflag)
...@@ -2801,17 +2664,12 @@ There are only a few functions special to module objects. ...@@ -2801,17 +2664,12 @@ There are only a few functions special to module objects.
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.
.. versionchanged:: 2.2
Allowed subtypes to be accepted.
.. cfunction:: int PyModule_CheckExact(PyObject *p) .. cfunction:: int PyModule_CheckExact(PyObject *p)
Return true if *p* is a module object, but not a subtype of Return true if *p* is a module object, but not a subtype of
:cdata:`PyModule_Type`. :cdata:`PyModule_Type`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyModule_New(const char *name) .. cfunction:: PyObject* PyModule_New(const char *name)
...@@ -2863,8 +2721,6 @@ There are only a few functions special to module objects. ...@@ -2863,8 +2721,6 @@ There are only a few functions special to module objects.
be used from the module's initialization function. This steals a reference to be used from the module's initialization function. This steals a reference to
*value*. Return ``-1`` on error, ``0`` on success. *value*. Return ``-1`` on error, ``0`` on success.
.. versionadded:: 2.0
.. cfunction:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value) .. cfunction:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
...@@ -2872,8 +2728,6 @@ There are only a few functions special to module objects. ...@@ -2872,8 +2728,6 @@ There are only a few functions special to module objects.
used from the module's initialization function. Return ``-1`` on error, ``0`` on used from the module's initialization function. Return ``-1`` on error, ``0`` on
success. success.
.. versionadded:: 2.0
.. cfunction:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value) .. cfunction:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
...@@ -2881,8 +2735,6 @@ There are only a few functions special to module objects. ...@@ -2881,8 +2735,6 @@ There are only a few functions special to module objects.
used from the module's initialization function. The string *value* must be used from the module's initialization function. The string *value* must be
null-terminated. Return ``-1`` on error, ``0`` on success. null-terminated. Return ``-1`` on error, ``0`` on success.
.. versionadded:: 2.0
.. _iterator-objects: .. _iterator-objects:
...@@ -2902,15 +2754,11 @@ sentinel value is returned. ...@@ -2902,15 +2754,11 @@ sentinel value is returned.
one-argument form of the :func:`iter` built-in function for built-in sequence one-argument form of the :func:`iter` built-in function for built-in sequence
types. types.
.. versionadded:: 2.2
.. cfunction:: int PySeqIter_Check(op) .. cfunction:: int PySeqIter_Check(op)
Return true if the type of *op* is :cdata:`PySeqIter_Type`. Return true if the type of *op* is :cdata:`PySeqIter_Type`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PySeqIter_New(PyObject *seq) .. cfunction:: PyObject* PySeqIter_New(PyObject *seq)
...@@ -2918,23 +2766,17 @@ sentinel value is returned. ...@@ -2918,23 +2766,17 @@ sentinel value is returned.
iteration ends when the sequence raises :exc:`IndexError` for the subscripting iteration ends when the sequence raises :exc:`IndexError` for the subscripting
operation. operation.
.. versionadded:: 2.2
.. cvar:: PyTypeObject PyCallIter_Type .. cvar:: PyTypeObject PyCallIter_Type
Type object for iterator objects returned by :cfunc:`PyCallIter_New` and the Type object for iterator objects returned by :cfunc:`PyCallIter_New` and the
two-argument form of the :func:`iter` built-in function. two-argument form of the :func:`iter` built-in function.
.. versionadded:: 2.2
.. cfunction:: int PyCallIter_Check(op) .. cfunction:: int PyCallIter_Check(op)
Return true if the type of *op* is :cdata:`PyCallIter_Type`. Return true if the type of *op* is :cdata:`PyCallIter_Type`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel) .. cfunction:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel)
...@@ -2943,8 +2785,6 @@ sentinel value is returned. ...@@ -2943,8 +2785,6 @@ sentinel value is returned.
return the next item in the iteration. When *callable* returns a value equal to return the next item in the iteration. When *callable* returns a value equal to
*sentinel*, the iteration will be terminated. *sentinel*, the iteration will be terminated.
.. versionadded:: 2.2
.. _descriptor-objects: .. _descriptor-objects:
...@@ -2954,38 +2794,27 @@ Descriptor Objects ...@@ -2954,38 +2794,27 @@ Descriptor Objects
"Descriptors" are objects that describe some attribute of an object. They are "Descriptors" are objects that describe some attribute of an object. They are
found in the dictionary of type objects. found in the dictionary of type objects.
.. XXX document these!
.. cvar:: PyTypeObject PyProperty_Type .. cvar:: PyTypeObject PyProperty_Type
The type object for the built-in descriptor types. The type object for the built-in descriptor types.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset) .. cfunction:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset)
.. versionadded:: 2.2
.. cfunction:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth) .. cfunction:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
.. versionadded:: 2.2
.. cfunction:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth) .. cfunction:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
.. versionadded:: 2.2
.. cfunction:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped) .. cfunction:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
.. versionadded:: 2.2
.. cfunction:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method) .. cfunction:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
.. versionadded:: 2.3
.. cfunction:: int PyDescr_IsData(PyObject *descr) .. cfunction:: int PyDescr_IsData(PyObject *descr)
...@@ -2993,13 +2822,9 @@ found in the dictionary of type objects. ...@@ -2993,13 +2822,9 @@ found in the dictionary of type objects.
false if it describes a method. *descr* must be a descriptor object; there is false if it describes a method. *descr* must be a descriptor object; there is
no error checking. no error checking.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyWrapper_New(PyObject *, PyObject *) .. cfunction:: PyObject* PyWrapper_New(PyObject *, PyObject *)
.. versionadded:: 2.2
.. _slice-objects: .. _slice-objects:
...@@ -3054,8 +2879,6 @@ Slice Objects ...@@ -3054,8 +2879,6 @@ Slice Objects
Returns 0 on success and -1 on error with exception set. Returns 0 on success and -1 on error with exception set.
.. versionadded:: 2.3
.. _weakrefobjects: .. _weakrefobjects:
...@@ -3072,22 +2895,16 @@ as much as it can. ...@@ -3072,22 +2895,16 @@ as much as it can.
Return true if *ob* is either a reference or proxy object. Return true if *ob* is either a reference or proxy object.
.. versionadded:: 2.2
.. cfunction:: int PyWeakref_CheckRef(ob) .. cfunction:: int PyWeakref_CheckRef(ob)
Return true if *ob* is a reference object. Return true if *ob* is a reference object.
.. versionadded:: 2.2
.. cfunction:: int PyWeakref_CheckProxy(ob) .. cfunction:: int PyWeakref_CheckProxy(ob)
Return true if *ob* is a proxy object. Return true if *ob* is a proxy object.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback) .. cfunction:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback)
...@@ -3100,8 +2917,6 @@ as much as it can. ...@@ -3100,8 +2917,6 @@ as much as it can.
weakly-referencable object, or if *callback* is not callable, ``None``, or weakly-referencable object, or if *callback* is not callable, ``None``, or
*NULL*, this will return *NULL* and raise :exc:`TypeError`. *NULL*, this will return *NULL* and raise :exc:`TypeError`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback) .. cfunction:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
...@@ -3114,24 +2929,18 @@ as much as it can. ...@@ -3114,24 +2929,18 @@ as much as it can.
is not a weakly-referencable object, or if *callback* is not callable, is not a weakly-referencable object, or if *callback* is not callable,
``None``, or *NULL*, this will return *NULL* and raise :exc:`TypeError`. ``None``, or *NULL*, this will return *NULL* and raise :exc:`TypeError`.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyWeakref_GetObject(PyObject *ref) .. cfunction:: PyObject* PyWeakref_GetObject(PyObject *ref)
Return the referenced object from a weak reference, *ref*. If the referent is Return the referenced object from a weak reference, *ref*. If the referent is
no longer live, returns ``None``. no longer live, returns ``None``.
.. versionadded:: 2.2
.. cfunction:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref) .. cfunction:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
Similar to :cfunc:`PyWeakref_GetObject`, but implemented as a macro that does no Similar to :cfunc:`PyWeakref_GetObject`, but implemented as a macro that does no
error checking. error checking.
.. versionadded:: 2.2
.. _cobjects: .. _cobjects:
...@@ -3305,111 +3114,84 @@ used by the following macros. ...@@ -3305,111 +3114,84 @@ used by the following macros.
Type-check macros: Type-check macros:
.. cfunction:: int PyDate_Check(PyObject *ob) .. cfunction:: int PyDate_Check(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_DateType` or a subtype of Return true if *ob* is of type :cdata:`PyDateTime_DateType` or a subtype of
:cdata:`PyDateTime_DateType`. *ob* must not be *NULL*. :cdata:`PyDateTime_DateType`. *ob* must not be *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyDate_CheckExact(PyObject *ob) .. cfunction:: int PyDate_CheckExact(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_DateType`. *ob* must not be Return true if *ob* is of type :cdata:`PyDateTime_DateType`. *ob* must not be
*NULL*. *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_Check(PyObject *ob) .. cfunction:: int PyDateTime_Check(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType` or a subtype of Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType` or a subtype of
:cdata:`PyDateTime_DateTimeType`. *ob* must not be *NULL*. :cdata:`PyDateTime_DateTimeType`. *ob* must not be *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_CheckExact(PyObject *ob) .. cfunction:: int PyDateTime_CheckExact(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType`. *ob* must not Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType`. *ob* must not
be *NULL*. be *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyTime_Check(PyObject *ob) .. cfunction:: int PyTime_Check(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_TimeType` or a subtype of Return true if *ob* is of type :cdata:`PyDateTime_TimeType` or a subtype of
:cdata:`PyDateTime_TimeType`. *ob* must not be *NULL*. :cdata:`PyDateTime_TimeType`. *ob* must not be *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyTime_CheckExact(PyObject *ob) .. cfunction:: int PyTime_CheckExact(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_TimeType`. *ob* must not be Return true if *ob* is of type :cdata:`PyDateTime_TimeType`. *ob* must not be
*NULL*. *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyDelta_Check(PyObject *ob) .. cfunction:: int PyDelta_Check(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_DeltaType` or a subtype of Return true if *ob* is of type :cdata:`PyDateTime_DeltaType` or a subtype of
:cdata:`PyDateTime_DeltaType`. *ob* must not be *NULL*. :cdata:`PyDateTime_DeltaType`. *ob* must not be *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyDelta_CheckExact(PyObject *ob) .. cfunction:: int PyDelta_CheckExact(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_DeltaType`. *ob* must not be Return true if *ob* is of type :cdata:`PyDateTime_DeltaType`. *ob* must not be
*NULL*. *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyTZInfo_Check(PyObject *ob) .. cfunction:: int PyTZInfo_Check(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType` or a subtype of Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType` or a subtype of
:cdata:`PyDateTime_TZInfoType`. *ob* must not be *NULL*. :cdata:`PyDateTime_TZInfoType`. *ob* must not be *NULL*.
.. versionadded:: 2.4
.. cfunction:: int PyTZInfo_CheckExact(PyObject *ob) .. cfunction:: int PyTZInfo_CheckExact(PyObject *ob)
Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType`. *ob* must not be Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType`. *ob* must not be
*NULL*. *NULL*.
.. versionadded:: 2.4
Macros to create objects: Macros to create objects:
.. cfunction:: PyObject* PyDate_FromDate(int year, int month, int day) .. cfunction:: PyObject* PyDate_FromDate(int year, int month, int day)
Return a ``datetime.date`` object with the specified year, month and day. Return a ``datetime.date`` object with the specified year, month and day.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond) .. cfunction:: PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond)
Return a ``datetime.datetime`` object with the specified year, month, day, hour, Return a ``datetime.datetime`` object with the specified year, month, day, hour,
minute, second and microsecond. minute, second and microsecond.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond) .. cfunction:: PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond)
Return a ``datetime.time`` object with the specified hour, minute, second and Return a ``datetime.time`` object with the specified hour, minute, second and
microsecond. microsecond.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyDelta_FromDSU(int days, int seconds, int useconds) .. cfunction:: PyObject* PyDelta_FromDSU(int days, int seconds, int useconds)
...@@ -3418,116 +3200,88 @@ Macros to create objects: ...@@ -3418,116 +3200,88 @@ Macros to create objects:
number of microseconds and seconds lie in the ranges documented for number of microseconds and seconds lie in the ranges documented for
``datetime.timedelta`` objects. ``datetime.timedelta`` objects.
.. versionadded:: 2.4
Macros to extract fields from date objects. The argument must be an instance of Macros to extract fields from date objects. The argument must be an instance of
:cdata:`PyDateTime_Date`, including subclasses (such as :cdata:`PyDateTime_Date`, including subclasses (such as
:cdata:`PyDateTime_DateTime`). The argument must not be *NULL*, and the type is :cdata:`PyDateTime_DateTime`). The argument must not be *NULL*, and the type is
not checked: not checked:
.. cfunction:: int PyDateTime_GET_YEAR(PyDateTime_Date *o) .. cfunction:: int PyDateTime_GET_YEAR(PyDateTime_Date *o)
Return the year, as a positive int. Return the year, as a positive int.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_GET_MONTH(PyDateTime_Date *o) .. cfunction:: int PyDateTime_GET_MONTH(PyDateTime_Date *o)
Return the month, as an int from 1 through 12. Return the month, as an int from 1 through 12.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_GET_DAY(PyDateTime_Date *o) .. cfunction:: int PyDateTime_GET_DAY(PyDateTime_Date *o)
Return the day, as an int from 1 through 31. Return the day, as an int from 1 through 31.
.. versionadded:: 2.4
Macros to extract fields from datetime objects. The argument must be an Macros to extract fields from datetime objects. The argument must be an
instance of :cdata:`PyDateTime_DateTime`, including subclasses. The argument instance of :cdata:`PyDateTime_DateTime`, including subclasses. The argument
must not be *NULL*, and the type is not checked: must not be *NULL*, and the type is not checked:
.. cfunction:: int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o) .. cfunction:: int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o)
Return the hour, as an int from 0 through 23. Return the hour, as an int from 0 through 23.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o) .. cfunction:: int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o)
Return the minute, as an int from 0 through 59. Return the minute, as an int from 0 through 59.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o) .. cfunction:: int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o)
Return the second, as an int from 0 through 59. Return the second, as an int from 0 through 59.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o) .. cfunction:: int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o)
Return the microsecond, as an int from 0 through 999999. Return the microsecond, as an int from 0 through 999999.
.. versionadded:: 2.4
Macros to extract fields from time objects. The argument must be an instance of Macros to extract fields from time objects. The argument must be an instance of
:cdata:`PyDateTime_Time`, including subclasses. The argument must not be *NULL*, :cdata:`PyDateTime_Time`, including subclasses. The argument must not be *NULL*,
and the type is not checked: and the type is not checked:
.. cfunction:: int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o) .. cfunction:: int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o)
Return the hour, as an int from 0 through 23. Return the hour, as an int from 0 through 23.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o) .. cfunction:: int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o)
Return the minute, as an int from 0 through 59. Return the minute, as an int from 0 through 59.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o) .. cfunction:: int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o)
Return the second, as an int from 0 through 59. Return the second, as an int from 0 through 59.
.. versionadded:: 2.4
.. cfunction:: int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o) .. cfunction:: int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o)
Return the microsecond, as an int from 0 through 999999. Return the microsecond, as an int from 0 through 999999.
.. versionadded:: 2.4
Macros for the convenience of modules implementing the DB API: Macros for the convenience of modules implementing the DB API:
.. cfunction:: PyObject* PyDateTime_FromTimestamp(PyObject *args) .. cfunction:: PyObject* PyDateTime_FromTimestamp(PyObject *args)
Create and return a new ``datetime.datetime`` object given an argument tuple Create and return a new ``datetime.datetime`` object given an argument tuple
suitable for passing to ``datetime.datetime.fromtimestamp()``. suitable for passing to ``datetime.datetime.fromtimestamp()``.
.. versionadded:: 2.4
.. cfunction:: PyObject* PyDate_FromTimestamp(PyObject *args) .. cfunction:: PyObject* PyDate_FromTimestamp(PyObject *args)
Create and return a new ``datetime.date`` object given an argument tuple Create and return a new ``datetime.date`` object given an argument tuple
suitable for passing to ``datetime.date.fromtimestamp()``. suitable for passing to ``datetime.date.fromtimestamp()``.
.. versionadded:: 2.4
.. _setobjects: .. _setobjects:
...@@ -3541,8 +3295,6 @@ Set Objects ...@@ -3541,8 +3295,6 @@ Set Objects
object: set object: set
object: frozenset object: frozenset
.. versionadded:: 2.5
This section details the public API for :class:`set` and :class:`frozenset` This section details the public API for :class:`set` and :class:`frozenset`
objects. Any functionality not listed below is best accessed using the either objects. Any functionality not listed below is best accessed using the either
the abstract object protocol (including :cfunc:`PyObject_CallMethod`, the abstract object protocol (including :cfunc:`PyObject_CallMethod`,
......
...@@ -257,8 +257,6 @@ in various ways. There is a separate error indicator for each thread. ...@@ -257,8 +257,6 @@ in various ways. There is a separate error indicator for each thread.
Similar to :cfunc:`PyErr_SetFromWindowsErr`, with an additional parameter Similar to :cfunc:`PyErr_SetFromWindowsErr`, with an additional parameter
specifying the exception type to be raised. Availability: Windows. specifying the exception type to be raised. Availability: Windows.
.. versionadded:: 2.3
.. cfunction:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename) .. cfunction:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename)
...@@ -272,8 +270,6 @@ in various ways. There is a separate error indicator for each thread. ...@@ -272,8 +270,6 @@ in various ways. There is a separate error indicator for each thread.
Similar to :cfunc:`PyErr_SetFromWindowsErrWithFilename`, with an additional Similar to :cfunc:`PyErr_SetFromWindowsErrWithFilename`, with an additional
parameter specifying the exception type to be raised. Availability: Windows. parameter specifying the exception type to be raised. Availability: Windows.
.. versionadded:: 2.3
.. cfunction:: void PyErr_BadInternalCall() .. cfunction:: void PyErr_BadInternalCall()
...@@ -399,7 +395,7 @@ the variables: ...@@ -399,7 +395,7 @@ the variables:
+------------------------------------+----------------------------+----------+ +------------------------------------+----------------------------+----------+
| C Name | Python Name | Notes | | C Name | Python Name | Notes |
+====================================+============================+==========+ +====================================+============================+==========+
| :cdata:`PyExc_BaseException` | :exc:`BaseException` | (1), (4) | | :cdata:`PyExc_BaseException` | :exc:`BaseException` | \(1) |
+------------------------------------+----------------------------+----------+ +------------------------------------+----------------------------+----------+
| :cdata:`PyExc_Exception` | :exc:`Exception` | \(1) | | :cdata:`PyExc_Exception` | :exc:`Exception` | \(1) |
+------------------------------------+----------------------------+----------+ +------------------------------------+----------------------------+----------+
...@@ -497,19 +493,3 @@ Notes: ...@@ -497,19 +493,3 @@ Notes:
(3) (3)
Only defined on Windows; protect code that uses this by testing that the Only defined on Windows; protect code that uses this by testing that the
preprocessor macro ``MS_WINDOWS`` is defined. preprocessor macro ``MS_WINDOWS`` is defined.
(4)
.. versionadded:: 2.5
Deprecation of String Exceptions
================================
.. index:: single: BaseException (built-in exception)
All exceptions built into Python or provided in the standard library are derived
from :exc:`BaseException`.
String exceptions are still supported in the interpreter to allow existing code
to run unmodified, but this will also change in a future release.
...@@ -42,8 +42,6 @@ Initialization, Finalization, and Threads ...@@ -42,8 +42,6 @@ Initialization, Finalization, and Threads
*initsigs* is 0, it skips initialization registration of signal handlers, which *initsigs* is 0, it skips initialization registration of signal handlers, which
might be useful when Python is embedded. might be useful when Python is embedded.
.. versionadded:: 2.4
.. cfunction:: int Py_IsInitialized() .. cfunction:: int Py_IsInitialized()
...@@ -290,8 +288,6 @@ Initialization, Finalization, and Threads ...@@ -290,8 +288,6 @@ Initialization, Finalization, and Threads
was built from. This number is a string because it may contain a trailing 'M' was built from. This number is a string because it may contain a trailing 'M'
if Python was built from a mixed revision source tree. if Python was built from a mixed revision source tree.
.. versionadded:: 2.5
.. cfunction:: const char* Py_GetPlatform() .. cfunction:: const char* Py_GetPlatform()
...@@ -570,8 +566,6 @@ supports the creation of additional interpreters (using ...@@ -570,8 +566,6 @@ supports the creation of additional interpreters (using
avoid calls to the locking API when running single-threaded. This function is avoid calls to the locking API when running single-threaded. This function is
not available when thread support is disabled at compile time. not available when thread support is disabled at compile time.
.. versionadded:: 2.4
.. cfunction:: void PyEval_AcquireLock() .. cfunction:: void PyEval_AcquireLock()
...@@ -719,10 +713,6 @@ created. ...@@ -719,10 +713,6 @@ created.
is available. If this function returns *NULL*, no exception has been raised and is available. If this function returns *NULL*, no exception has been raised and
the caller should assume no current thread state is available. the caller should assume no current thread state is available.
.. versionchanged:: 2.3
Previously this could only be called when a current thread is active, and *NULL*
meant that an exception was raised.
.. cfunction:: int PyThreadState_SetAsyncExc(long id, PyObject *exc) .. cfunction:: int PyThreadState_SetAsyncExc(long id, PyObject *exc)
...@@ -734,8 +724,6 @@ created. ...@@ -734,8 +724,6 @@ created.
zero if the thread id isn't found. If *exc* is :const:`NULL`, the pending zero if the thread id isn't found. If *exc* is :const:`NULL`, the pending
exception (if any) for the thread is cleared. This raises no exceptions. exception (if any) for the thread is cleared. This raises no exceptions.
.. versionadded:: 2.3
.. cfunction:: PyGILState_STATE PyGILState_Ensure() .. cfunction:: PyGILState_STATE PyGILState_Ensure()
...@@ -758,8 +746,6 @@ created. ...@@ -758,8 +746,6 @@ created.
When the function returns, the current thread will hold the GIL. Failure is a When the function returns, the current thread will hold the GIL. Failure is a
fatal error. fatal error.
.. versionadded:: 2.3
.. cfunction:: void PyGILState_Release(PyGILState_STATE) .. cfunction:: void PyGILState_Release(PyGILState_STATE)
...@@ -771,8 +757,6 @@ created. ...@@ -771,8 +757,6 @@ created.
Every call to :cfunc:`PyGILState_Ensure` must be matched by a call to Every call to :cfunc:`PyGILState_Ensure` must be matched by a call to
:cfunc:`PyGILState_Release` on the same thread. :cfunc:`PyGILState_Release` on the same thread.
.. versionadded:: 2.3
.. _profiling: .. _profiling:
...@@ -908,29 +892,21 @@ These functions are only intended to be used by advanced debugging tools. ...@@ -908,29 +892,21 @@ These functions are only intended to be used by advanced debugging tools.
Return the interpreter state object at the head of the list of all such objects. Return the interpreter state object at the head of the list of all such objects.
.. versionadded:: 2.2
.. cfunction:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp) .. cfunction:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp)
Return the next interpreter state object after *interp* from the list of all Return the next interpreter state object after *interp* from the list of all
such objects. such objects.
.. versionadded:: 2.2
.. cfunction:: PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *interp) .. cfunction:: PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *interp)
Return the a pointer to the first :ctype:`PyThreadState` object in the list of Return the a pointer to the first :ctype:`PyThreadState` object in the list of
threads associated with the interpreter *interp*. threads associated with the interpreter *interp*.
.. versionadded:: 2.2
.. cfunction:: PyThreadState* PyThreadState_Next(PyThreadState *tstate) .. cfunction:: PyThreadState* PyThreadState_Next(PyThreadState *tstate)
Return the next thread state object after *tstate* from the list of all such Return the next thread state object after *tstate* from the list of all such
objects belonging to the same :ctype:`PyInterpreterState` object. objects belonging to the same :ctype:`PyInterpreterState` object.
.. versionadded:: 2.2
...@@ -67,49 +67,41 @@ Allocating Objects on the Heap ...@@ -67,49 +67,41 @@ Allocating Objects on the Heap
.. cfunction:: PyObject* Py_InitModule(char *name, PyMethodDef *methods) .. cfunction:: PyObject* Py_InitModule(char *name, PyMethodDef *methods)
Create a new module object based on a name and table of functions, returning the Create a new module object based on a name and table of functions, returning
new module object. the new module object; the *methods* argument can be *NULL* if no methods are
to be defined for the module.
.. versionchanged:: 2.3
Older versions of Python did not support *NULL* as the value for the *methods*
argument.
.. cfunction:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc) .. cfunction:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc)
Create a new module object based on a name and table of functions, returning the Create a new module object based on a name and table of functions, returning
new module object. If *doc* is non-*NULL*, it will be used to define the the new module object. The *methods* argument can be *NULL* if no methods
docstring for the module. are to be defined for the module. If *doc* is non-*NULL*, it will be used to
define the docstring for the module.
.. versionchanged:: 2.3
Older versions of Python did not support *NULL* as the value for the *methods*
argument.
.. cfunction:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver) .. cfunction:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver)
Create a new module object based on a name and table of functions, returning the Create a new module object based on a name and table of functions, returning
new module object. If *doc* is non-*NULL*, it will be used to define the the new module object. The *methods* argument can be *NULL* if no methods
docstring for the module. If *self* is non-*NULL*, it will passed to the are to be defined for the module. If *doc* is non-*NULL*, it will be used to
functions of the module as their (otherwise *NULL*) first parameter. (This was define the docstring for the module. If *self* is non-*NULL*, it will passed
added as an experimental feature, and there are no known uses in the current to the functions of the module as their (otherwise *NULL*) first parameter.
version of Python.) For *apiver*, the only value which should be passed is (This was added as an experimental feature, and there are no known uses in
defined by the constant :const:`PYTHON_API_VERSION`. the current version of Python.) For *apiver*, the only value which should be
passed is defined by the constant :const:`PYTHON_API_VERSION`.
.. note:: .. note::
Most uses of this function should probably be using the :cfunc:`Py_InitModule3` Most uses of this function should probably be using the :cfunc:`Py_InitModule3`
instead; only use this if you are sure you need it. instead; only use this if you are sure you need it.
.. versionchanged:: 2.3
Older versions of Python did not support *NULL* as the value for the *methods*
argument.
.. cvar:: PyObject _Py_NoneStruct .. cvar:: PyObject _Py_NoneStruct
Object which is visible in Python as ``None``. This should only be accessed Object which is visible in Python as ``None``. This should only be accessed
using the ``Py_None`` macro, which evaluates to a pointer to this object. using the :cmacro:`Py_None` macro, which evaluates to a pointer to this
object.
.. _common-structs: .. _common-structs:
...@@ -263,6 +255,7 @@ convention flags can be combined with a binding flag. ...@@ -263,6 +255,7 @@ convention flags can be combined with a binding flag.
:ctype:`PyObject\*` parameter representing the single argument. :ctype:`PyObject\*` parameter representing the single argument.
.. XXX deprecated, should be removed
.. data:: METH_OLDARGS .. data:: METH_OLDARGS
This calling convention is deprecated. The method must be of type This calling convention is deprecated. The method must be of type
...@@ -286,8 +279,6 @@ method. ...@@ -286,8 +279,6 @@ method.
instance of the type. This is used to create *class methods*, similar to what instance of the type. This is used to create *class methods*, similar to what
is created when using the :func:`classmethod` built-in function. is created when using the :func:`classmethod` built-in function.
.. versionadded:: 2.3
.. data:: METH_STATIC .. data:: METH_STATIC
...@@ -297,8 +288,6 @@ method. ...@@ -297,8 +288,6 @@ method.
of the type. This is used to create *static methods*, similar to what is of the type. This is used to create *static methods*, similar to what is
created when using the :func:`staticmethod` built-in function. created when using the :func:`staticmethod` built-in function.
.. versionadded:: 2.3
One other constant controls whether a method is loaded in place of another One other constant controls whether a method is loaded in place of another
definition with the same method name. definition with the same method name.
...@@ -314,8 +303,6 @@ definition with the same method name. ...@@ -314,8 +303,6 @@ definition with the same method name.
object and will co-exist with the slot. This is helpful because calls to object and will co-exist with the slot. This is helpful because calls to
PyCFunctions are optimized more than wrapper object calls. PyCFunctions are optimized more than wrapper object calls.
.. versionadded:: 2.4
.. cfunction:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name) .. cfunction:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name)
...@@ -1718,8 +1705,6 @@ must name its arguments exactly *visit* and *arg*: ...@@ -1718,8 +1705,6 @@ must name its arguments exactly *visit* and *arg*:
return 0; return 0;
} }
.. versionadded:: 2.4
The :attr:`tp_clear` handler must be of the :ctype:`inquiry` type, or *NULL* if The :attr:`tp_clear` handler must be of the :ctype:`inquiry` type, or *NULL* if
the object is immutable. the object is immutable.
......
...@@ -61,12 +61,11 @@ objects. ...@@ -61,12 +61,11 @@ objects.
It is a good idea to use this macro whenever decrementing the value of a It is a good idea to use this macro whenever decrementing the value of a
variable that might be traversed during garbage collection. variable that might be traversed during garbage collection.
.. versionadded:: 2.4
The following functions are for runtime dynamic embedding of Python: The following functions are for runtime dynamic embedding of Python:
``Py_IncRef(PyObject \*o)``, `Py_DecRef(PyObject \*o)``. They are ``Py_IncRef(PyObject \*o)``, `Py_DecRef(PyObject \*o)``. They are simply
simply exported function versions of :cfunc:`Py_XINCREF` and exported function versions of :cfunc:`Py_XINCREF` and :cfunc:`Py_XDECREF`,
:cfunc:`Py_XDECREF`, respectively. respectively.
The following functions or macros are only for use within the interpreter core: The following functions or macros are only for use within the interpreter core:
:cfunc:`_Py_Dealloc`, :cfunc:`_Py_ForgetReference`, :cfunc:`_Py_NewReference`, :cfunc:`_Py_Dealloc`, :cfunc:`_Py_ForgetReference`, :cfunc:`_Py_NewReference`,
......
...@@ -121,6 +121,7 @@ Importing Modules ...@@ -121,6 +121,7 @@ Importing Modules
.. index:: .. index::
single: package variable; __all__ single: package variable; __all__
single: __all__ (package variable) single: __all__ (package variable)
single: modules (in module sys)
This is a simplified interface to :cfunc:`PyImport_ImportModuleEx` below, This is a simplified interface to :cfunc:`PyImport_ImportModuleEx` below,
leaving the *globals* and *locals* arguments set to *NULL*. When the *name* leaving the *globals* and *locals* arguments set to *NULL*. When the *name*
...@@ -135,11 +136,6 @@ Importing Modules ...@@ -135,11 +136,6 @@ Importing Modules
to find out. Starting with Python 2.4, a failing import of a module no longer to find out. Starting with Python 2.4, a failing import of a module no longer
leaves the module in ``sys.modules``. leaves the module in ``sys.modules``.
.. versionchanged:: 2.4
failing imports remove incomplete module objects.
.. index:: single: modules (in module sys)
.. cfunction:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist) .. cfunction:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
...@@ -155,20 +151,16 @@ Importing Modules ...@@ -155,20 +151,16 @@ Importing Modules
when a submodule of a package was requested is normally the top-level package, when a submodule of a package was requested is normally the top-level package,
unless a non-empty *fromlist* was given. unless a non-empty *fromlist* was given.
.. versionchanged:: 2.4 Failing imports remove incomplete module objects, like with
failing imports remove incomplete module objects. :cfunc:`PyImport_ImportModule`.
.. cfunction:: PyObject* PyImport_Import(PyObject *name) .. cfunction:: PyObject* PyImport_Import(PyObject *name)
.. index::
module: rexec
module: ihooks
This is a higher-level interface that calls the current "import hook function". This is a higher-level interface that calls the current "import hook function".
It invokes the :func:`__import__` function from the ``__builtins__`` of the It invokes the :func:`__import__` function from the ``__builtins__`` of the
current globals. This means that the import is done using whatever import hooks current globals. This means that the import is done using whatever import hooks
are installed in the current environment, e.g. by :mod:`rexec` or :mod:`ihooks`. are installed in the current environment.
.. cfunction:: PyObject* PyImport_ReloadModule(PyObject *m) .. cfunction:: PyObject* PyImport_ReloadModule(PyObject *m)
...@@ -213,9 +205,6 @@ Importing Modules ...@@ -213,9 +205,6 @@ Importing Modules
If *name* points to a dotted name of the form ``package.module``, any package If *name* points to a dotted name of the form ``package.module``, any package
structures not already created will still not be created. structures not already created will still not be created.
.. versionchanged:: 2.4
*name* is removed from ``sys.modules`` in error cases.
.. cfunction:: long PyImport_GetMagicNumber() .. cfunction:: long PyImport_GetMagicNumber()
...@@ -345,25 +334,18 @@ upon unmarshalling. *Py_MARSHAL_VERSION* indicates the current file format ...@@ -345,25 +334,18 @@ upon unmarshalling. *Py_MARSHAL_VERSION* indicates the current file format
Marshal a :ctype:`long` integer, *value*, to *file*. This will only write the Marshal a :ctype:`long` integer, *value*, to *file*. This will only write the
least-significant 32 bits of *value*; regardless of the size of the native least-significant 32 bits of *value*; regardless of the size of the native
:ctype:`long` type. :ctype:`long` type. *version* indicates the file format.
.. versionchanged:: 2.4
*version* indicates the file format.
.. cfunction:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version) .. cfunction:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version)
Marshal a Python object, *value*, to *file*. Marshal a Python object, *value*, to *file*.
.. versionchanged:: 2.4
*version* indicates the file format. *version* indicates the file format.
.. cfunction:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version) .. cfunction:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version)
Return a string object containing the marshalled representation of *value*. Return a string object containing the marshalled representation of *value*.
.. versionchanged:: 2.4
*version* indicates the file format. *version* indicates the file format.
...@@ -557,8 +539,6 @@ variable(s) whose address should be passed. ...@@ -557,8 +539,6 @@ variable(s) whose address should be passed.
Convert a Python integer to a tiny int without overflow checking, stored in a C Convert a Python integer to a tiny int without overflow checking, stored in a C
:ctype:`unsigned char`. :ctype:`unsigned char`.
.. versionadded:: 2.3
``h`` (integer) [short int] ``h`` (integer) [short int]
Convert a Python integer to a C :ctype:`short int`. Convert a Python integer to a C :ctype:`short int`.
...@@ -566,8 +546,6 @@ variable(s) whose address should be passed. ...@@ -566,8 +546,6 @@ variable(s) whose address should be passed.
Convert a Python integer to a C :ctype:`unsigned short int`, without overflow Convert a Python integer to a C :ctype:`unsigned short int`, without overflow
checking. checking.
.. versionadded:: 2.3
``i`` (integer) [int] ``i`` (integer) [int]
Convert a Python integer to a plain C :ctype:`int`. Convert a Python integer to a plain C :ctype:`int`.
...@@ -575,8 +553,6 @@ variable(s) whose address should be passed. ...@@ -575,8 +553,6 @@ variable(s) whose address should be passed.
Convert a Python integer to a C :ctype:`unsigned int`, without overflow Convert a Python integer to a C :ctype:`unsigned int`, without overflow
checking. checking.
.. versionadded:: 2.3
``l`` (integer) [long int] ``l`` (integer) [long int]
Convert a Python integer to a C :ctype:`long int`. Convert a Python integer to a C :ctype:`long int`.
...@@ -584,8 +560,6 @@ variable(s) whose address should be passed. ...@@ -584,8 +560,6 @@ variable(s) whose address should be passed.
Convert a Python integer or long integer to a C :ctype:`unsigned long` without Convert a Python integer or long integer to a C :ctype:`unsigned long` without
overflow checking. overflow checking.
.. versionadded:: 2.3
``L`` (integer) [PY_LONG_LONG] ``L`` (integer) [PY_LONG_LONG]
Convert a Python integer to a C :ctype:`long long`. This format is only Convert a Python integer to a C :ctype:`long long`. This format is only
available on platforms that support :ctype:`long long` (or :ctype:`_int64` on available on platforms that support :ctype:`long long` (or :ctype:`_int64` on
...@@ -596,13 +570,9 @@ variable(s) whose address should be passed. ...@@ -596,13 +570,9 @@ variable(s) whose address should be passed.
without overflow checking. This format is only available on platforms that without overflow checking. This format is only available on platforms that
support :ctype:`unsigned long long` (or :ctype:`unsigned _int64` on Windows). support :ctype:`unsigned long long` (or :ctype:`unsigned _int64` on Windows).
.. versionadded:: 2.3
``n`` (integer) [Py_ssize_t] ``n`` (integer) [Py_ssize_t]
Convert a Python integer or long integer to a C :ctype:`Py_ssize_t`. Convert a Python integer or long integer to a C :ctype:`Py_ssize_t`.
.. versionadded:: 2.5
``c`` (string of length 1) [char] ``c`` (string of length 1) [char]
Convert a Python character, represented as a string of length 1, to a C Convert a Python character, represented as a string of length 1, to a C
:ctype:`char`. :ctype:`char`.
...@@ -677,13 +647,6 @@ variable(s) whose address should be passed. ...@@ -677,13 +647,6 @@ variable(s) whose address should be passed.
in *items*. The C arguments must correspond to the individual format units in in *items*. The C arguments must correspond to the individual format units in
*items*. Format units for sequences may be nested. *items*. Format units for sequences may be nested.
.. note::
Prior to Python version 1.5.2, this format specifier only accepted a tuple
containing the individual parameters, not an arbitrary sequence. Code which
previously caused :exc:`TypeError` to be raised here may now proceed without an
exception. This is not expected to be a problem for existing code.
It is possible to pass Python long integers where integers are requested; It is possible to pass Python long integers where integers are requested;
however no proper range checking is done --- the most significant bits are however no proper range checking is done --- the most significant bits are
silently truncated when the receiving field is too small to receive the value silently truncated when the receiving field is too small to receive the value
...@@ -798,8 +761,6 @@ return true, otherwise they return false and raise an appropriate exception. ...@@ -798,8 +761,6 @@ return true, otherwise they return false and raise an appropriate exception.
PyArg_ParseTuple(args, "O|O:ref", &object, &callback) PyArg_ParseTuple(args, "O|O:ref", &object, &callback)
.. versionadded:: 2.2
.. cfunction:: PyObject* Py_BuildValue(const char *format, ...) .. cfunction:: PyObject* Py_BuildValue(const char *format, ...)
...@@ -898,8 +859,6 @@ return true, otherwise they return false and raise an appropriate exception. ...@@ -898,8 +859,6 @@ return true, otherwise they return false and raise an appropriate exception.
``n`` (int) [Py_ssize_t] ``n`` (int) [Py_ssize_t]
Convert a C :ctype:`Py_ssize_t` to a Python integer or long integer. Convert a C :ctype:`Py_ssize_t` to a Python integer or long integer.
.. versionadded:: 2.5
``c`` (string of length 1) [char] ``c`` (string of length 1) [char]
Convert a C :ctype:`int` representing a character to a Python string of length Convert a C :ctype:`int` representing a character to a Python string of length
1. 1.
...@@ -1010,8 +969,6 @@ The following functions provide locale-independent string to number conversions. ...@@ -1010,8 +969,6 @@ The following functions provide locale-independent string to number conversions.
:cfunc:`PyOS_ascii_strtod` should typically be used for reading configuration :cfunc:`PyOS_ascii_strtod` should typically be used for reading configuration
files or other non-user input that should be locale independent. files or other non-user input that should be locale independent.
.. versionadded:: 2.4
See the Unix man page :manpage:`strtod(2)` for details. See the Unix man page :manpage:`strtod(2)` for details.
...@@ -1025,14 +982,10 @@ The following functions provide locale-independent string to number conversions. ...@@ -1025,14 +982,10 @@ The following functions provide locale-independent string to number conversions.
The return value is a pointer to *buffer* with the converted string or NULL if The return value is a pointer to *buffer* with the converted string or NULL if
the conversion failed. the conversion failed.
.. versionadded:: 2.4
.. cfunction:: double PyOS_ascii_atof(const char *nptr) .. cfunction:: double PyOS_ascii_atof(const char *nptr)
Convert a string to a :ctype:`double` in a locale-independent way. Convert a string to a :ctype:`double` in a locale-independent way.
.. versionadded:: 2.4
See the Unix man page :manpage:`atof(2)` for details. See the Unix man page :manpage:`atof(2)` for details.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment