@@ -1680,12 +1680,18 @@ \section{Object Protocol \label{object}}
16801680
16811681
16821682\begin {cfuncdesc }{PyObject*}{PyObject_Type}{PyObject *o}
1683- On success, returns a type object corresponding to the object
1684- type of object \var {o}. On failure, returns \NULL {}. This is
1685- equivalent to the Python expression \samp {type(\var {o})}.
1683+ When \var {o} is non-\NULL , returns a type object corresponding to the
1684+ object type of object \var {o}. On failure, raises
1685+ \exception {SystemError} and returns \NULL . This is equivalent to the
1686+ Python expression \code {type(\var {o})}.
16861687\bifuncindex {type}
16871688\end {cfuncdesc }
16881689
1690+ \begin {cfuncdesc }{int}{PyObject_TypeCheck}{PyObject *o, PyTypeObject *type}
1691+ Return true if the object \var {o} is of type \var {type} or a subtype
1692+ of \var {type}. Both parameters must be non-\NULL .
1693+ \end {cfuncdesc }
1694+
16891695\begin {cfuncdesc }{int}{PyObject_Length}{PyObject *o}
16901696Return the length of object \var {o}. If the object \var {o} provides
16911697both sequence and mapping protocols, the sequence length is
@@ -2365,7 +2371,15 @@ \subsection{Plain Integer Objects \label{intObjects}}
23652371\end {cvardesc }
23662372
23672373\begin {cfuncdesc }{int}{PyInt_Check}{PyObject* o}
2368- Returns true if \var {o} is of type \cdata {PyInt_Type}.
2374+ Returns true if \var {o} is of type \cdata {PyInt_Type} or a subtype of
2375+ \cdata {PyInt_Type}.
2376+ \versionchanged [Allowed subtypes to be accepted]{2.2}
2377+ \end {cfuncdesc }
2378+
2379+ \begin {cfuncdesc }{int}{PyInt_CheckExact}{PyObject* o}
2380+ Returns true if \var {o} is of type \cdata {PyInt_Type}, but not a
2381+ subtype of \cdata {PyInt_Type}.
2382+ \versionadded {2.2}
23692383\end {cfuncdesc }
23702384
23712385\begin {cfuncdesc }{PyObject*}{PyInt_FromLong}{long ival}
@@ -2410,7 +2424,15 @@ \subsection{Long Integer Objects \label{longObjects}}
24102424\end {cvardesc }
24112425
24122426\begin {cfuncdesc }{int}{PyLong_Check}{PyObject *p}
2413- Returns true if its argument is a \ctype {PyLongObject}.
2427+ Returns true if its argument is a \ctype {PyLongObject} or a subtype of
2428+ \ctype {PyLongObject}.
2429+ \versionchanged [Allowed subtypes to be accepted]{2.2}
2430+ \end {cfuncdesc }
2431+
2432+ \begin {cfuncdesc }{int}{PyLong_CheckExact}{PyObject *p}
2433+ Returns true if its argument is a \ctype {PyLongObject}, but not a
2434+ subtype of \ctype {PyLongObject}.
2435+ \versionadded {2.2}
24142436\end {cfuncdesc }
24152437
24162438\begin {cfuncdesc }{PyObject*}{PyLong_FromLong}{long v}
@@ -2423,11 +2445,54 @@ \subsection{Long Integer Objects \label{longObjects}}
24232445long}, or \NULL {} on failure.
24242446\end {cfuncdesc }
24252447
2448+ \begin {cfuncdesc }{PyObject*}{PyLong_FromLongLong}{long long v}
2449+ Returns a new \ctype {PyLongObject} object from a C \ctype {long long},
2450+ or \NULL {} on failure.
2451+ \end {cfuncdesc }
2452+
2453+ \begin {cfuncdesc }{PyObject*}{PyLong_FromUnsignedLongLong}{unsigned long long v}
2454+ Returns a new \ctype {PyLongObject} object from a C \ctype {unsigned
2455+ long long}, or \NULL {} on failure.
2456+ \end {cfuncdesc }
2457+
24262458\begin {cfuncdesc }{PyObject*}{PyLong_FromDouble}{double v}
24272459Returns a new \ctype {PyLongObject} object from the integer part of
24282460\var {v}, or \NULL {} on failure.
24292461\end {cfuncdesc }
24302462
2463+ \begin {cfuncdesc }{PyObject*}{PyLong_FromString}{char *str, char **pend,
2464+ int base}
2465+ Return a new \ctype {PyLongObject} based on the string value in
2466+ \var {str}, which is interpreted according to the radix in \var {base}.
2467+ If \var {pend} is non-\NULL , \code {*\var {pend}} will point to the first
2468+ character in \var {str} which follows the representation of the
2469+ number. If \var {base} is \code {0}, the radix will be determined base
2470+ on the leading characters of \var {str}: if \var {str} starts with
2471+ \code {'0x'} or \code {'0X'}, radix 16 will be used; if \var {str} starts
2472+ with \code {'0'}, radix 8 will be used; otherwise radix 10 will be
2473+ used. If \var {base} is not \code {0}, it must be between \code {2} and
2474+ \code {36}, inclusive. Leading spaces are ignored. If there are no
2475+ digits, \exception {ValueError} will be raised.
2476+ \end {cfuncdesc }
2477+
2478+ \begin {cfuncdesc }{PyObject*}{PyLong_FromUnicode}{Py_UNICODE *u,
2479+ int length, int base}
2480+ Convert a sequence of Unicode digits to a Python long integer value.
2481+ The first parameter, \var {u}, points to the first character of the
2482+ Unicode string, \var {length} gives the number of characters, and
2483+ \var {base} is the radix for the conversion. The radix must be in the
2484+ range [2, 36]; if it is out of range, \exception {ValueError} will be
2485+ raised.
2486+ \versionadded {1.6}
2487+ \end {cfuncdesc }
2488+
2489+ \begin {cfuncdesc }{PyObject*}{PyLong_FromVoidPtr}{void *p}
2490+ Create a Python integer or long integer from the pointer \var {p}. The
2491+ pointer value can be retrieved from the resulting value using
2492+ \cfunction {PyLong_AsVoidPtr()}.
2493+ \versionadded {1.5.2}
2494+ \end {cfuncdesc }
2495+
24312496\begin {cfuncdesc }{long}{PyLong_AsLong}{PyObject *pylong}
24322497Returns a C \ctype {long} representation of the contents of
24332498\var {pylong}. If \var {pylong} is greater than
@@ -2442,23 +2507,36 @@ \subsection{Long Integer Objects \label{longObjects}}
24422507is raised.\withsubitem {(built-in exception)}{\ttindex {OverflowError}}
24432508\end {cfuncdesc }
24442509
2510+ \begin {cfuncdesc }{long long}{PyLong_AsLongLong}{PyObject *pylong}
2511+ Return a C \ctype {long long} from a Python long integer. If
2512+ \var {pylong} cannot be represented as a \ctype {long long}, an
2513+ \exception {OverflowError} will be raised.
2514+ \versionadded {2.2}
2515+ \end {cfuncdesc }
2516+
2517+ \begin {cfuncdesc }{unsigned long long}{PyLong_AsUnsignedLongLong}{PyObject
2518+ *pylong}
2519+ Return a C \ctype {unsigned long long} from a Python long integer. If
2520+ \var {pylong} cannot be represented as an \ctype {unsigned long long},
2521+ an \exception {OverflowError} will be raised if the value is positive,
2522+ or a \exception {TypeError} will be raised if the value is negative.
2523+ \versionadded {2.2}
2524+ \end {cfuncdesc }
2525+
24452526\begin {cfuncdesc }{double}{PyLong_AsDouble}{PyObject *pylong}
2446- Returns a C \ctype {double} representation of the contents of \var {pylong}.
2527+ Returns a C \ctype {double} representation of the contents of
2528+ \var {pylong}. If \var {pylong} cannot be approximately represented as
2529+ a \ctype {double}, an \exception {OverflowError} exception is raised and
2530+ \code {-1.0} will be returned.
24472531\end {cfuncdesc }
24482532
2449- \begin {cfuncdesc }{PyObject*}{PyLong_FromString}{char *str, char **pend,
2450- int base}
2451- Return a new \ctype {PyLongObject} based on the string value in
2452- \var {str}, which is interpreted according to the radix in \var {base}.
2453- If \var {pend} is non-\NULL , \code {*\var {pend}} will point to the first
2454- character in \var {str} which follows the representation of the
2455- number. If \var {base} is \code {0}, the radix will be determined base
2456- on the leading characters of \var {str}: if \var {str} starts with
2457- \code {'0x'} or \code {'0X'}, radix 16 will be used; if \var {str} starts
2458- with \code {'0'}, radix 8 will be used; otherwise radix 10 will be
2459- used. If \var {base} is not \code {0}, it must be between \code {2} and
2460- \code {36}, inclusive. Leading spaces are ignored. If there are no
2461- digits, \exception {ValueError} will be raised.
2533+ \begin {cfuncdesc }{void*}{PyLong_AsVoidPtr}{PyObject *pylong}
2534+ Convert a Python integer or long integer \var {pylong} to a C
2535+ \ctype {void} pointer. If \var {pylong} cannot be converted, an
2536+ \exception {OverflowError} will be raised. This is only assured to
2537+ produce a usable \ctype {void} pointer for values created with
2538+ \cfunction {PyLong_FromVoidPtr()}.
2539+ \versionadded {1.5.2}
24622540\end {cfuncdesc }
24632541
24642542
@@ -2477,7 +2555,15 @@ \subsection{Floating Point Objects \label{floatObjects}}
24772555\end {cvardesc }
24782556
24792557\begin {cfuncdesc }{int}{PyFloat_Check}{PyObject *p}
2480- Returns true if its argument is a \ctype {PyFloatObject}.
2558+ Returns true if its argument is a \ctype {PyFloatObject} or a subtype
2559+ of \ctype {PyFloatObject}.
2560+ \versionchanged [Allowed subtypes to be accepted]{2.2}
2561+ \end {cfuncdesc }
2562+
2563+ \begin {cfuncdesc }{int}{PyFloat_CheckExact}{PyObject *p}
2564+ Returns true if its argument is a \ctype {PyFloatObject}, but not a
2565+ subtype of \ctype {PyFloatObject}.
2566+ \versionadded {2.2}
24812567\end {cfuncdesc }
24822568
24832569\begin {cfuncdesc }{PyObject*}{PyFloat_FromDouble}{double v}
@@ -2569,7 +2655,15 @@ \subsubsection{Complex Numbers as Python Objects}
25692655\end {cvardesc }
25702656
25712657\begin {cfuncdesc }{int}{PyComplex_Check}{PyObject *p}
2572- Returns true if its argument is a \ctype {PyComplexObject}.
2658+ Returns true if its argument is a \ctype {PyComplexObject} or a subtype
2659+ of \ctype {PyComplexObject}.
2660+ \versionchanged [Allowed subtypes to be accepted]{2.2}
2661+ \end {cfuncdesc }
2662+
2663+ \begin {cfuncdesc }{int}{PyComplex_CheckExact}{PyObject *p}
2664+ Returns true if its argument is a \ctype {PyComplexObject}, but not a
2665+ subtype of \ctype {PyComplexObject}.
2666+ \versionadded {2.2}
25732667\end {cfuncdesc }
25742668
25752669\begin {cfuncdesc }{PyObject*}{PyComplex_FromCComplex}{Py_complex v}
@@ -2620,7 +2714,15 @@ \subsection{String Objects \label{stringObjects}}
26202714\end {cvardesc }
26212715
26222716\begin {cfuncdesc }{int}{PyString_Check}{PyObject *o}
2623- Returns true if the object \var {o} is a string object.
2717+ Returns true if the object \var {o} is a string object or an instance
2718+ of a subtype of the string type.
2719+ \versionchanged [Allowed subtypes to be accepted]{2.2}
2720+ \end {cfuncdesc }
2721+
2722+ \begin {cfuncdesc }{int}{PyString_CheckExact}{PyObject *o}
2723+ Returns true if the object \var {o} is a string object, but not an
2724+ instance of a subtype of the string type.
2725+ \versionadded {2.2}
26242726\end {cfuncdesc }
26252727
26262728\begin {cfuncdesc }{PyObject*}{PyString_FromString}{const char *v}
@@ -2835,7 +2937,15 @@ \subsection{Unicode Objects \label{unicodeObjects}}
28352937checks and to access internal read-only data of Unicode objects:
28362938
28372939\begin {cfuncdesc }{int}{PyUnicode_Check}{PyObject *o}
2838- Returns true if the object \var {o} is a Unicode object.
2940+ Returns true if the object \var {o} is a Unicode object or an instance
2941+ of a Unicode subtype.
2942+ \versionchanged [Allowed subtypes to be accepted]{2.2}
2943+ \end {cfuncdesc }
2944+
2945+ \begin {cfuncdesc }{int}{PyUnicode_CheckExact}{PyObject *o}
2946+ Returns true if the object \var {o} is a Unicode object, but not an
2947+ instance of a subtype.
2948+ \versionadded {2.2}
28392949\end {cfuncdesc }
28402950
28412951\begin {cfuncdesc }{int}{PyUnicode_GET_SIZE}{PyObject *o}
@@ -3623,7 +3733,15 @@ \subsection{Tuple Objects \label{tupleObjects}}
36233733\end {cvardesc }
36243734
36253735\begin {cfuncdesc }{int}{PyTuple_Check}{PyObject *p}
3626- Return true if the argument is a tuple object.
3736+ Return true if \var {p} is a tuple object or an instance of a subtype
3737+ of the tuple type.
3738+ \versionchanged [Allowed subtypes to be accepted]{2.2}
3739+ \end {cfuncdesc }
3740+
3741+ \begin {cfuncdesc }{int}{PyTuple_CheckExact}{PyObject *p}
3742+ Return true if \var {p} is a tuple object, but not an instance of
3743+ a subtype of the tuple type.
3744+ \versionadded {2.2}
36273745\end {cfuncdesc }
36283746
36293747\begin {cfuncdesc }{PyObject*}{PyTuple_New}{int len}
@@ -3983,7 +4101,15 @@ \subsection{File Objects \label{fileObjects}}
39834101\end {cvardesc }
39844102
39854103\begin {cfuncdesc }{int}{PyFile_Check}{PyObject *p}
3986- Returns true if its argument is a \ctype {PyFileObject}.
4104+ Returns true if its argument is a \ctype {PyFileObject} or a subtype of
4105+ \ctype {PyFileObject}.
4106+ \versionchanged [Allowed subtypes to be accepted]{2.2}
4107+ \end {cfuncdesc }
4108+
4109+ \begin {cfuncdesc }{int}{PyFile_CheckExact}{PyObject *p}
4110+ Returns true if its argument is a \ctype {PyFileObject}, but not a
4111+ subtype of \ctype {PyFileObject}.
4112+ \versionadded {2.2}
39874113\end {cfuncdesc }
39884114
39894115\begin {cfuncdesc }{PyObject*}{PyFile_FromString}{char *filename, char *mode}
@@ -4159,7 +4285,15 @@ \subsection{Module Objects \label{moduleObjects}}
41594285\end {cvardesc }
41604286
41614287\begin {cfuncdesc }{int}{PyModule_Check}{PyObject *p}
4162- Returns true if its argument is a module object.
4288+ Returns true if \var {p} is a module object, or a subtype of a
4289+ module object.
4290+ \versionchanged [Allowed subtypes to be accepted]{2.2}
4291+ \end {cfuncdesc }
4292+
4293+ \begin {cfuncdesc }{int}{PyModule_CheckExact}{PyObject *p}
4294+ Returns true if \var {p} is a module object, but not a subtype of
4295+ \cdata {PyModule_Type}.
4296+ \versionadded {2.2}
41634297\end {cfuncdesc }
41644298
41654299\begin {cfuncdesc }{PyObject*}{PyModule_New}{char *name}
0 commit comments