Commit 543d5ca5 authored by Stefan Behnel's avatar Stefan Behnel

more .pxd cleanups

--HG--
rename : Cython/Includes/python_string.pxd => Cython/Includes/python_bytes.pxd
rename : Cython/Includes/python_parse.pxd => Cython/Includes/python_getargs.pxd
parent a265ec1a
...@@ -79,7 +79,7 @@ cdef extern from "Python.h": ...@@ -79,7 +79,7 @@ cdef extern from "Python.h":
# fastest). If fortran is 'A', then it does not matter and the # fastest). If fortran is 'A', then it does not matter and the
# copy will be made in whatever way is more efficient. # copy will be made in whatever way is more efficient.
int PyObject_CopyData(object dest, object src) int PyObject_CopyData(object dest, object src) except -1
# Copy the data from the src buffer to the buffer of destination # Copy the data from the src buffer to the buffer of destination
bint PyBuffer_IsContiguous(Py_buffer *view, char fort) bint PyBuffer_IsContiguous(Py_buffer *view, char fort)
......
from python_ref cimport PyObject
cdef extern from "Python.h":
ctypedef struct va_list
############################################################################
# 7.3.1 String Objects
############################################################################
# These functions raise TypeError when expecting a string
# parameter and are called with a non-string parameter.
# PyStringObject
# This subtype of PyObject represents a Python bytes object.
# PyTypeObject PyBytes_Type
# This instance of PyTypeObject represents the Python bytes type;
# it is the same object as bytes and types.BytesType in the Python
# layer.
bint PyBytes_Check(object o)
# Return true if the object o is a string object or an instance of
# a subtype of the string type.
bint PyBytes_CheckExact(object o)
# Return true if the object o is a string object, but not an instance of a subtype of the string type.
object PyBytes_FromString(char *v)
# Return value: New reference.
# Return a new string object with the value v on success, and NULL
# on failure. The parameter v must not be NULL; it will not be
# checked.
object PyBytes_FromStringAndSize(char *v, Py_ssize_t len)
# Return value: New reference.
# Return a new string object with the value v and length len on
# success, and NULL on failure. If v is NULL, the contents of the
# string are uninitialized.
object PyBytes_FromFormat(char *format, ...)
# Return value: New reference.
# Take a C printf()-style format string and a variable number of
# arguments, calculate the size of the resulting Python string and
# return a string with the values formatted into it. The variable
# arguments must be C types and must correspond exactly to the
# format characters in the format string. The following format
# characters are allowed:
# Format Characters Type Comment
# %% n/a The literal % character.
# %c int A single character, represented as an C int.
# %d int Exactly equivalent to printf("%d").
# %u unsigned int Exactly equivalent to printf("%u").
# %ld long Exactly equivalent to printf("%ld").
# %lu unsigned long Exactly equivalent to printf("%lu").
# %zd Py_ssize_t Exactly equivalent to printf("%zd").
# %zu size_t Exactly equivalent to printf("%zu").
# %i int Exactly equivalent to printf("%i").
# %x int Exactly equivalent to printf("%x").
# %s char* A null-terminated C character array.
# %p void* The hex representation of a C pointer.
# Mostly equivalent to printf("%p") except that it is guaranteed to
# start with the literal 0x regardless of what the platform's printf
# yields.
# 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.
object PyBytes_FromFormatV(char *format, va_list vargs)
# Return value: New reference.
# Identical to PyBytes_FromFormat() except that it takes exactly two arguments.
Py_ssize_t PyBytes_Size(object string) except -1
# Return the length of the string in string object string.
Py_ssize_t PyBytes_GET_SIZE(object string)
# Macro form of PyBytes_Size() but without error checking.
char* PyBytes_AsString(object string) except NULL
# Return a NUL-terminated representation of the contents of
# string. The pointer refers to the internal buffer of string, not
# a copy. The data must not be modified in any way, unless the
# string was just created using PyBytes_FromStringAndSize(NULL,
# size). It must not be deallocated. If string is a Unicode
# object, this function computes the default encoding of string
# and operates on that. If string is not a string object at all,
# PyBytes_AsString() returns NULL and raises TypeError.
char* PyBytes_AS_STRING(object string)
# Macro form of PyBytes_AsString() but without error
# checking. Only string objects are supported; no Unicode objects
# should be passed.
int PyBytes_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1
# Return a NULL-terminated representation of the contents of the
# object obj through the output variables buffer and length.
#
# The function accepts both string and Unicode objects as
# input. For Unicode objects it returns the default encoded
# version of the object. If length is NULL, the resulting buffer
# may not contain NUL characters; if it does, the function returns
# -1 and a TypeError is raised.
# The buffer refers to an internal string buffer of obj, not a
# copy. The data must not be modified in any way, unless the
# string was just created using PyBytes_FromStringAndSize(NULL,
# size). It must not be deallocated. If string is a Unicode
# object, this function computes the default encoding of string
# and operates on that. If string is not a string object at all,
# PyBytes_AsStringAndSize() returns -1 and raises TypeError.
void PyBytes_Concat(PyObject **string, object newpart)
# Create a new string object in *string containing the contents of
# newpart appended to string; the caller will own the new
# reference. The reference to the old value of string will be
# stolen. If the new string cannot be created, the old reference
# to string will still be discarded and the value of *string will
# be set to NULL; the appropriate exception will be set.
void PyBytes_ConcatAndDel(PyObject **string, object newpart)
# Create a new string object in *string containing the contents of
# newpart appended to string. This version decrements the
# reference count of newpart.
int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1
# A way to resize a string object even though it is
# ``immutable''. Only use this to build up a brand new string
# object; don't use this if the string may already be known in
# other parts of the code. It is an error to call this function if
# the refcount on the input string object is not one. Pass the
# address of an existing string object as an lvalue (it may be
# written into), and the new size desired. On success, *string
# holds the resized string object and 0 is returned; the address
# in *string may differ from its input value. If the reallocation
# fails, the original string object at *string is deallocated,
# *string is set to NULL, a memory exception is set, and -1 is
# returned.
object PyBytes_Format(object format, object args)
# Return value: New reference. Return a new string object from
# format and args. Analogous to format % args. The args argument
# must be a tuple.
void PyBytes_InternInPlace(PyObject **string)
# Intern the argument *string in place. The argument must be the
# address of a pointer variable pointing to a Python string
# object. If there is an existing interned string that is the same
# as *string, it sets *string to it (decrementing the reference
# count of the old string object and incrementing the reference
# count of the interned string object), otherwise it leaves
# *string alone and interns it (incrementing its reference
# count). (Clarification: even though there is a lot of talk about
# reference counts, think of this function as
# reference-count-neutral; you own the object after the call if
# and only if you owned it before the call.)
object PyBytes_InternFromString(char *v)
# Return value: New reference.
# A combination of PyBytes_FromString() and
# PyBytes_InternInPlace(), returning either a new string object
# that has been interned, or a new (``owned'') reference to an
# earlier interned string object with the same value.
object PyBytes_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
# Return value: New reference.
# Create an object by decoding size bytes of the encoded buffer s
# using the codec registered for encoding. encoding and errors
# have the same meaning as the parameters of the same name in the
# unicode() built-in function. The codec to be used is looked up
# using the Python codec registry. Return NULL if an exception was
# raised by the codec.
object PyBytes_AsDecodedObject(object str, char *encoding, char *errors)
# Return value: New reference.
# Decode a string object by passing it to the codec registered for
# encoding and return the result as Python object. encoding and
# errors have the same meaning as the parameters of the same name
# in the string encode() method. The codec to be used is looked up
# using the Python codec registry. Return NULL if an exception was
# raised by the codec.
object PyBytes_Encode(char *s, Py_ssize_t size, char *encoding, char *errors)
# Return value: New reference.
# Encode the char buffer of the given size by passing it to the
# codec registered for encoding and return a Python
# object. encoding and errors have the same meaning as the
# parameters of the same name in the string encode() method. The
# codec to be used is looked up using the Python codec
# registry. Return NULL if an exception was raised by the codec.
object PyBytes_AsEncodedObject(object str, char *encoding, char *errors)
# Return value: New reference.
# Encode a string object using the codec registered for encoding
# and return the result as Python object. encoding and errors have
# the same meaning as the parameters of the same name in the
# string encode() method. The codec to be used is looked up using
# the Python codec registry. Return NULL if an exception was
# raised by the codec.
...@@ -25,13 +25,13 @@ cdef extern from "Python.h": ...@@ -25,13 +25,13 @@ cdef extern from "Python.h":
# be called when the object is reclaimed. The desc argument can be # be called when the object is reclaimed. The desc argument can be
# used to pass extra callback data for the destructor function. # used to pass extra callback data for the destructor function.
void* PyCObject_AsVoidPtr(object self) void* PyCObject_AsVoidPtr(object self) except? NULL
# Return the object void * that the PyCObject self was created with. # Return the object void * that the PyCObject self was created with.
void* PyCObject_GetDesc(object self) void* PyCObject_GetDesc(object self) except? NULL
# Return the description void * that the PyCObject self was created with. # Return the description void * that the PyCObject self was created with.
int PyCObject_SetVoidPtr(object self, void* cobj) int PyCObject_SetVoidPtr(object self, void* cobj) except 0
# Set the void pointer inside self to cobj. The PyCObject must not # Set the void pointer inside self to cobj. The PyCObject must not
# have an associated destructor. Return true on success, false on # have an associated destructor. Return true on success, false on
# failure. # failure.
...@@ -29,11 +29,13 @@ cdef extern from "Python.h": ...@@ -29,11 +29,13 @@ cdef extern from "Python.h":
# Return value: New reference. # Return value: New reference.
# Return a new PyComplexObject object from real and imag. # Return a new PyComplexObject object from real and imag.
double PyComplex_RealAsDouble(object op) double PyComplex_RealAsDouble(object op) except? -1
# Return the real part of op as a C double. # Return the real part of op as a C double.
double PyComplex_ImagAsDouble(object op) double PyComplex_ImagAsDouble(object op) except? -1
# Return the imaginary part of op as a C double. # Return the imaginary part of op as a C double.
Py_complex PyComplex_AsCComplex(object op) Py_complex PyComplex_AsCComplex(object op)
# Return the Py_complex value of the complex number op. # Return the Py_complex value of the complex number op.
#
# Returns (-1+0i) in case of an error
...@@ -95,7 +95,7 @@ cdef extern from "Python.h": ...@@ -95,7 +95,7 @@ cdef extern from "Python.h":
# dictionary p, as in the dictionary method values() (see the # dictionary p, as in the dictionary method values() (see the
# Python Library Reference). # Python Library Reference).
Py_ssize_t PyDict_Size(object p) Py_ssize_t PyDict_Size(object p) except -1
# Return the number of items in the dictionary. This is equivalent # Return the number of items in the dictionary. This is equivalent
# to "len(p)" on a dictionary. # to "len(p)" on a dictionary.
......
...@@ -53,7 +53,7 @@ cdef extern from "Python.h": ...@@ -53,7 +53,7 @@ cdef extern from "Python.h":
# of a class, in the case of a class exception, or it may the a # of a class, in the case of a class exception, or it may the a
# subclass of the expected exception.) # subclass of the expected exception.)
int PyErr_ExceptionMatches(object exc) bint PyErr_ExceptionMatches(object exc)
# Equivalent to "PyErr_GivenExceptionMatches(PyErr_Occurred(), # Equivalent to "PyErr_GivenExceptionMatches(PyErr_Occurred(),
# exc)". This should only be called when an exception is actually # exc)". This should only be called when an exception is actually
# set; a memory access violation will occur if no exception has # set; a memory access violation will occur if no exception has
...@@ -126,7 +126,7 @@ cdef extern from "Python.h": ...@@ -126,7 +126,7 @@ cdef extern from "Python.h":
void PyErr_SetNone(object type) void PyErr_SetNone(object type)
# This is a shorthand for "PyErr_SetObject(type, Py_None)". # This is a shorthand for "PyErr_SetObject(type, Py_None)".
int PyErr_BadArgument() int PyErr_BadArgument() except 0
# This is a shorthand for "PyErr_SetString(PyExc_TypeError, # This is a shorthand for "PyErr_SetString(PyExc_TypeError,
# message)", where message indicates that a built-in operation was # message)", where message indicates that a built-in operation was
...@@ -196,7 +196,7 @@ cdef extern from "Python.h": ...@@ -196,7 +196,7 @@ cdef extern from "Python.h":
# (e.g. a Python/C API function) was invoked with an illegal # (e.g. a Python/C API function) was invoked with an illegal
# argument. It is mostly for internal use. # argument. It is mostly for internal use.
int PyErr_WarnEx(object category, char *message, int stacklevel) int PyErr_WarnEx(object category, char *message, int stacklevel) except -1
# Issue a warning message. The category argument is a warning # Issue a warning message. The category argument is a warning
# category (see below) or NULL; the message argument is a message # category (see below) or NULL; the message argument is a message
# string. stacklevel is a positive number giving a number of stack # string. stacklevel is a positive number giving a number of stack
...@@ -205,14 +205,14 @@ cdef extern from "Python.h": ...@@ -205,14 +205,14 @@ cdef extern from "Python.h":
# function calling PyErr_WarnEx(), 2 is the function above that, # function calling PyErr_WarnEx(), 2 is the function above that,
# and so forth. # and so forth.
int PyErr_WarnExplicit(object category, char *message, char *filename, int lineno, char *module, object registry) int PyErr_WarnExplicit(object category, char *message, char *filename, int lineno, char *module, object registry) except -1
# Issue a warning message with explicit control over all warning # Issue a warning message with explicit control over all warning
# attributes. This is a straightforward wrapper around the Python # attributes. This is a straightforward wrapper around the Python
# function warnings.warn_explicit(), see there for more # function warnings.warn_explicit(), see there for more
# information. The module and registry arguments may be set to # information. The module and registry arguments may be set to
# NULL to get the default effect described there. # NULL to get the default effect described there.
int PyErr_CheckSignals() int PyErr_CheckSignals() except -1
# This function interacts with Python's signal handling. It checks # This function interacts with Python's signal handling. It checks
# whether a signal has been sent to the processes and if so, # whether a signal has been sent to the processes and if so,
# invokes the corresponding signal handler. If the signal module # invokes the corresponding signal handler. If the signal module
......
...@@ -31,9 +31,9 @@ cdef extern from "Python.h": ...@@ -31,9 +31,9 @@ cdef extern from "Python.h":
# Return value: New reference. # Return value: New reference.
# Create a PyFloatObject object from v, or NULL on failure. # Create a PyFloatObject object from v, or NULL on failure.
double PyFloat_AsDouble(object pyfloat) double PyFloat_AsDouble(object pyfloat) except? -1
# Return a C double representation of the contents of pyfloat. # Return a C double representation of the contents of pyfloat.
double PyFloat_AS_DOUBLE(object pyfloat) double PyFloat_AS_DOUBLE(object pyfloat) except? -1
# Return a C double representation of the contents of pyfloat, but # Return a C double representation of the contents of pyfloat, but
# without error checking. # without error checking.
...@@ -30,21 +30,21 @@ cdef extern from "Python.h": ...@@ -30,21 +30,21 @@ cdef extern from "Python.h":
# the code object, the argument defaults and closure are set to # the code object, the argument defaults and closure are set to
# NULL. # NULL.
PyObject* PyFunction_GetCode(object op) PyObject* PyFunction_GetCode(object op) except? NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the code object associated with the function object op. # Return the code object associated with the function object op.
PyObject* PyFunction_GetGlobals(object op) PyObject* PyFunction_GetGlobals(object op) except? NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the globals dictionary associated with the function object op. # Return the globals dictionary associated with the function object op.
PyObject* PyFunction_GetModule(object op) PyObject* PyFunction_GetModule(object op) except? NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the __module__ attribute of the function object op. This # Return the __module__ attribute of the function object op. This
# is normally a string containing the module name, but can be set # is normally a string containing the module name, but can be set
# to any other object by Python code. # to any other object by Python code.
PyObject* PyFunction_GetDefaults(object op) PyObject* PyFunction_GetDefaults(object op) except? NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the argument default values of the function object # Return the argument default values of the function object
# op. This can be a tuple of arguments or NULL. # op. This can be a tuple of arguments or NULL.
...@@ -54,7 +54,7 @@ cdef extern from "Python.h": ...@@ -54,7 +54,7 @@ cdef extern from "Python.h":
# op. defaults must be Py_None or a tuple. # op. defaults must be Py_None or a tuple.
# Raises SystemError and returns -1 on failure. # Raises SystemError and returns -1 on failure.
PyObject* PyFunction_GetClosure(object op) PyObject* PyFunction_GetClosure(object op) except? NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the closure associated with the function object op. This # Return the closure associated with the function object op. This
# can be NULL or a tuple of cell objects. # can be NULL or a tuple of cell objects.
......
from python_ref cimport PyObject
cdef extern from "Python.h": cdef extern from "Python.h":
ctypedef void PyObject
##################################################################### #####################################################################
# 5.5 Parsing arguments and building values # 5.5 Parsing arguments and building values
##################################################################### #####################################################################
ctypedef struct va_list ctypedef struct va_list
int PyArg_ParseTuple(PyObject *args, char *format, ...) int PyArg_ParseTuple(object args, char *format, ...) except 0
int PyArg_VaParse(PyObject *args, char *format, va_list vargs) int PyArg_VaParse(object args, char *format, va_list vargs) except 0
int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, char *format, char *keywords[], ...) int PyArg_ParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], ...) except 0
int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, char *format, char *keywords[], va_list vargs) int PyArg_VaParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], va_list vargs) except 0
int PyArg_Parse(PyObject *args, char *format, ...) int PyArg_Parse(object args, char *format, ...) except 0
int PyArg_UnpackTuple(PyObject *args, char *name, Py_ssize_t min, Py_ssize_t max, ...) int PyArg_UnpackTuple(object args, char *name, Py_ssize_t min, Py_ssize_t max, ...) except 0
...@@ -58,18 +58,18 @@ cdef extern from "Python.h": ...@@ -58,18 +58,18 @@ cdef extern from "Python.h":
long PyInt_AS_LONG(object io) long PyInt_AS_LONG(object io)
# Return the value of the object io. No error checking is performed. # Return the value of the object io. No error checking is performed.
unsigned long PyInt_AsUnsignedLongMask(object io) unsigned long PyInt_AsUnsignedLongMask(object io) except? -1
# Will first attempt to cast the object to a PyIntObject or # Will first attempt to cast the object to a PyIntObject or
# PyLongObject, if it is not already one, and then return its # PyLongObject, if it is not already one, and then return its
# value as unsigned long. This function does not check for # value as unsigned long. This function does not check for
# overflow. # overflow.
PY_LONG_LONG PyInt_AsUnsignedLongLongMask(object io) PY_LONG_LONG PyInt_AsUnsignedLongLongMask(object io) except? -1
# Will first attempt to cast the object to a PyIntObject or # Will first attempt to cast the object to a PyIntObject or
# PyLongObject, if it is not already one, and then return its # PyLongObject, if it is not already one, and then return its
# value as unsigned long long, without checking for overflow. # value as unsigned long long, without checking for overflow.
Py_ssize_t PyInt_AsSsize_t(object io) Py_ssize_t PyInt_AsSsize_t(object io) except? -1
# Will first attempt to cast the object to a PyIntObject or # Will first attempt to cast the object to a PyIntObject or
# PyLongObject, if it is not already one, and then return its # PyLongObject, if it is not already one, and then return its
# value as Py_ssize_t. # value as Py_ssize_t.
......
...@@ -22,14 +22,14 @@ cdef extern from "Python.h": ...@@ -22,14 +22,14 @@ cdef extern from "Python.h":
# Return true if p is a list object, but not an instance of a # Return true if p is a list object, but not an instance of a
# subtype of the list type. # subtype of the list type.
Py_ssize_t PyList_Size(object list) Py_ssize_t PyList_Size(object list) except -1
# Return the length of the list object in list; this is equivalent # Return the length of the list object in list; this is equivalent
# to "len(list)" on a list object. # to "len(list)" on a list object.
Py_ssize_t PyList_GET_SIZE(object list) Py_ssize_t PyList_GET_SIZE(object list)
# Macro form of PyList_Size() without error checking. # Macro form of PyList_Size() without error checking.
PyObject* PyList_GetItem(object list, Py_ssize_t index) PyObject* PyList_GetItem(object list, Py_ssize_t index) except NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the object at position pos in the list pointed to by # Return the object at position pos in the list pointed to by
# p. The position must be positive, indexing from the end of the # p. The position must be positive, indexing from the end of the
......
...@@ -72,32 +72,32 @@ cdef extern from "Python.h": ...@@ -72,32 +72,32 @@ cdef extern from "Python.h":
# PyLong_AsVoidPtr(). If the integer is larger than LONG_MAX, a # PyLong_AsVoidPtr(). If the integer is larger than LONG_MAX, a
# positive long integer is returned. # positive long integer is returned.
long PyLong_AsLong(object pylong) long PyLong_AsLong(object pylong) except? -1
# Return a C long representation of the contents of pylong. If # Return a C long representation of the contents of pylong. If
# pylong is greater than LONG_MAX, an OverflowError is raised. # pylong is greater than LONG_MAX, an OverflowError is raised.
unsigned long PyLong_AsUnsignedLong(object pylong) unsigned long PyLong_AsUnsignedLong(object pylong) except? -1
# Return a C unsigned long representation of the contents of # Return a C unsigned long representation of the contents of
# pylong. If pylong is greater than ULONG_MAX, an OverflowError is # pylong. If pylong is greater than ULONG_MAX, an OverflowError is
# raised. # raised.
PY_LONG_LONG PyLong_AsLongLong(object pylong) PY_LONG_LONG PyLong_AsLongLong(object pylong) except? -1
# Return a C long long from a Python long integer. If pylong # Return a C long long from a Python long integer. If pylong
# cannot be represented as a long long, an OverflowError will be # cannot be represented as a long long, an OverflowError will be
# raised. # raised.
uPY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong) uPY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong) except? -1
#unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong) #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong)
# Return a C unsigned long long from a Python long integer. If # Return a C unsigned long long from a Python long integer. If
# pylong cannot be represented as an unsigned long long, an # pylong cannot be represented as an unsigned long long, an
# OverflowError will be raised if the value is positive, or a # OverflowError will be raised if the value is positive, or a
# TypeError will be raised if the value is negative. # TypeError will be raised if the value is negative.
unsigned long PyLong_AsUnsignedLongMask(object io) unsigned long PyLong_AsUnsignedLongMask(object io) except? -1
# Return a C unsigned long from a Python long integer, without # Return a C unsigned long from a Python long integer, without
# checking for overflow. # checking for overflow.
uPY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io) uPY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io) except? -1
#unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io) #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io)
# Return a C unsigned long long from a Python long integer, # Return a C unsigned long long from a Python long integer,
# without checking for overflow. # without checking for overflow.
...@@ -107,7 +107,7 @@ cdef extern from "Python.h": ...@@ -107,7 +107,7 @@ cdef extern from "Python.h":
# pylong cannot be approximately represented as a double, an # pylong cannot be approximately represented as a double, an
# OverflowError exception is raised and -1.0 will be returned. # OverflowError exception is raised and -1.0 will be returned.
void* PyLong_AsVoidPtr(object pylong) void* PyLong_AsVoidPtr(object pylong) except? NULL
# Convert a Python integer or long integer pylong to a C void # Convert a Python integer or long integer pylong to a C void
# pointer. If pylong cannot be converted, an OverflowError will be # pointer. If pylong cannot be converted, an OverflowError will be
# raised. This is only assured to produce a usable void pointer # raised. This is only assured to produce a usable void pointer
......
...@@ -21,7 +21,7 @@ cdef extern from "Python.h": ...@@ -21,7 +21,7 @@ cdef extern from "Python.h":
# otherwise self should be NULL and class should be the class # otherwise self should be NULL and class should be the class
# which provides the unbound method.. # which provides the unbound method..
PyObject* PyMethod_Class(object meth) PyObject* PyMethod_Class(object meth) except NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the class object from which the method meth was created; # Return the class object from which the method meth was created;
# if this was created from an instance, it will be the class of # if this was created from an instance, it will be the class of
...@@ -31,7 +31,7 @@ cdef extern from "Python.h": ...@@ -31,7 +31,7 @@ cdef extern from "Python.h":
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Macro version of PyMethod_Class() which avoids error checking. # Macro version of PyMethod_Class() which avoids error checking.
PyObject* PyMethod_Function(object meth) PyObject* PyMethod_Function(object meth) except NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the function object associated with the method meth. # Return the function object associated with the method meth.
...@@ -39,7 +39,7 @@ cdef extern from "Python.h": ...@@ -39,7 +39,7 @@ cdef extern from "Python.h":
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Macro version of PyMethod_Function() which avoids error checking. # Macro version of PyMethod_Function() which avoids error checking.
PyObject* PyMethod_Self(object meth) PyObject* PyMethod_Self(object meth) except? NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the instance associated with the method meth if it is bound, otherwise return NULL. # Return the instance associated with the method meth if it is bound, otherwise return NULL.
......
...@@ -90,7 +90,7 @@ cdef extern from "Python.h": ...@@ -90,7 +90,7 @@ cdef extern from "Python.h":
# and .pyo files). The magic number should be present in the first # and .pyo files). The magic number should be present in the first
# four bytes of the bytecode file, in little-endian byte order. # four bytes of the bytecode file, in little-endian byte order.
PyObject* PyImport_GetModuleDict() PyObject* PyImport_GetModuleDict() except NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the dictionary used for the module administration # Return the dictionary used for the module administration
# (a.k.a. sys.modules). Note that this is a per-interpreter # (a.k.a. sys.modules). Note that this is a per-interpreter
...@@ -139,7 +139,7 @@ cdef extern from "Python.h": ...@@ -139,7 +139,7 @@ cdef extern from "Python.h":
# filled in; the caller is responsible for providing a __file__ # filled in; the caller is responsible for providing a __file__
# attribute. # attribute.
PyObject* PyModule_GetDict(object module) PyObject* PyModule_GetDict(object module) except NULL
# Return value: Borrowed reference. # Return value: Borrowed reference.
# Return the dictionary object that implements module's namespace; # Return the dictionary object that implements module's namespace;
# this object is the same as the __dict__ attribute of the module # this object is the same as the __dict__ attribute of the module
......
...@@ -236,7 +236,7 @@ cdef extern from "Python.h": ...@@ -236,7 +236,7 @@ cdef extern from "Python.h":
# Returns the o converted to a Python int or long on success or # Returns the o converted to a Python int or long on success or
# NULL with a TypeError exception raised on failure. # NULL with a TypeError exception raised on failure.
Py_ssize_t PyNumber_AsSsize_t(object o, object exc) Py_ssize_t PyNumber_AsSsize_t(object o, object exc) except? -1
# Returns o converted to a Py_ssize_t value if o can be # Returns o converted to a Py_ssize_t value if o can be
# interpreted as an integer. If o can be converted to a Python int # interpreted as an integer. If o can be converted to a Python int
# or long but the attempt to convert to a Py_ssize_t value would # or long but the attempt to convert to a Py_ssize_t value would
......
...@@ -49,7 +49,7 @@ cdef extern from "Python.h": ...@@ -49,7 +49,7 @@ cdef extern from "Python.h":
# PyCapsule_Import(). # PyCapsule_Import().
void* PyCapsule_GetPointer(object capsule, char *name) void* PyCapsule_GetPointer(object capsule, char *name) except? NULL
# Retrieve the pointer stored in the capsule. On failure, set an # Retrieve the pointer stored in the capsule. On failure, set an
# exception and return NULL. # exception and return NULL.
# #
...@@ -59,7 +59,7 @@ cdef extern from "Python.h": ...@@ -59,7 +59,7 @@ cdef extern from "Python.h":
# to compare capsule names. # to compare capsule names.
PyCapsule_Destructor PyCapsule_GetDestructor(object capsule) PyCapsule_Destructor PyCapsule_GetDestructor(object capsule) except? NULL
# Return the current destructor stored in the capsule. On failure, # Return the current destructor stored in the capsule. On failure,
# set an exception and return NULL. # set an exception and return NULL.
# #
...@@ -68,7 +68,7 @@ cdef extern from "Python.h": ...@@ -68,7 +68,7 @@ cdef extern from "Python.h":
# or PyErr_Occurred() to disambiguate. # or PyErr_Occurred() to disambiguate.
char* PyCapsule_GetName(object capsule) char* PyCapsule_GetName(object capsule) except? NULL
# Return the current name stored in the capsule. On failure, set # Return the current name stored in the capsule. On failure, set
# an exception and return NULL. # an exception and return NULL.
# #
...@@ -77,7 +77,7 @@ cdef extern from "Python.h": ...@@ -77,7 +77,7 @@ cdef extern from "Python.h":
# PyErr_Occurred() to disambiguate. # PyErr_Occurred() to disambiguate.
void* PyCapsule_GetContext(object capsule) void* PyCapsule_GetContext(object capsule) except? NULL
# Return the current context stored in the capsule. On failure, # Return the current context stored in the capsule. On failure,
# set an exception and return NULL. # set an exception and return NULL.
# #
...@@ -86,7 +86,7 @@ cdef extern from "Python.h": ...@@ -86,7 +86,7 @@ cdef extern from "Python.h":
# PyErr_Occurred() to disambiguate. # PyErr_Occurred() to disambiguate.
int PyCapsule_IsValid(object capsule, char *name) bint PyCapsule_IsValid(object capsule, char *name)
# Determines whether or not capsule is a valid capsule. A valid # Determines whether or not capsule is a valid capsule. A valid
# capsule is non-NULL, passes PyCapsule_CheckExact(), has a # capsule is non-NULL, passes PyCapsule_CheckExact(), has a
# non-NULL pointer stored in it, and its internal name matches the # non-NULL pointer stored in it, and its internal name matches the
...@@ -101,7 +101,7 @@ cdef extern from "Python.h": ...@@ -101,7 +101,7 @@ cdef extern from "Python.h":
# name passed in. Return 0 otherwise. This function will not fail. # name passed in. Return 0 otherwise. This function will not fail.
int PyCapsule_SetPointer(object capsule, void *pointer) int PyCapsule_SetPointer(object capsule, void *pointer) except -1
# Set the void pointer inside capsule to pointer. The pointer may # Set the void pointer inside capsule to pointer. The pointer may
# not be NULL. # not be NULL.
# #
...@@ -109,14 +109,14 @@ cdef extern from "Python.h": ...@@ -109,14 +109,14 @@ cdef extern from "Python.h":
# failure. # failure.
int PyCapsule_SetDestructor(object capsule, PyCapsule_Destructor destructor) int PyCapsule_SetDestructor(object capsule, PyCapsule_Destructor destructor) except -1
# Set the destructor inside capsule to destructor. # Set the destructor inside capsule to destructor.
# #
# Return 0 on success. Return nonzero and set an exception on # Return 0 on success. Return nonzero and set an exception on
# failure. # failure.
int PyCapsule_SetName(object capsule, char *name) int PyCapsule_SetName(object capsule, char *name) except -1
# Set the name inside capsule to name. If non-NULL, the name must # Set the name inside capsule to name. If non-NULL, the name must
# outlive the capsule. If the previous name stored in the capsule # outlive the capsule. If the previous name stored in the capsule
# was not NULL, no attempt is made to free it. # was not NULL, no attempt is made to free it.
...@@ -125,12 +125,12 @@ cdef extern from "Python.h": ...@@ -125,12 +125,12 @@ cdef extern from "Python.h":
# failure. # failure.
int PyCapsule_SetContext(object capsule, void *context) int PyCapsule_SetContext(object capsule, void *context) except -1
# Set the context pointer inside capsule to context. Return 0 on # Set the context pointer inside capsule to context. Return 0 on
# success. Return nonzero and set an exception on failure. # success. Return nonzero and set an exception on failure.
void* PyCapsule_Import(char *name, int no_block) void* PyCapsule_Import(char *name, int no_block) except? NULL
# Import a pointer to a C object from a capsule attribute in a # Import a pointer to a C object from a capsule attribute in a
# module. The name parameter should specify the full name to the # module. The name parameter should specify the full name to the
# attribute, as in module.attribute. The name stored in the # attribute, as in module.attribute. The name stored in the
......
...@@ -47,7 +47,7 @@ cdef extern from "Python.h": ...@@ -47,7 +47,7 @@ cdef extern from "Python.h":
bint PyFrozenSet_CheckExact(object p) bint PyFrozenSet_CheckExact(object p)
# Return true if p is a frozenset object but not an instance of a subtype. # Return true if p is a frozenset object but not an instance of a subtype.
PySet_New(object iterable) object PySet_New(object iterable)
# Return value: New reference. # Return value: New reference.
# Return a new set containing objects returned by the # Return a new set containing objects returned by the
# iterable. The iterable may be NULL to create a new empty # iterable. The iterable may be NULL to create a new empty
...@@ -55,7 +55,7 @@ cdef extern from "Python.h": ...@@ -55,7 +55,7 @@ cdef extern from "Python.h":
# TypeError if iterable is not actually iterable. The constructor # TypeError if iterable is not actually iterable. The constructor
# is also useful for copying a set (c=set(s)). # is also useful for copying a set (c=set(s)).
PyFrozenSet_New(object iterable) object PyFrozenSet_New(object iterable)
# Return value: New reference. # Return value: New reference.
# Return a new frozenset containing objects returned by the # Return a new frozenset containing objects returned by the
# iterable. The iterable may be NULL to create a new empty # iterable. The iterable may be NULL to create a new empty
......
...@@ -68,7 +68,7 @@ cdef extern from "Python.h": ...@@ -68,7 +68,7 @@ cdef extern from "Python.h":
# Return value: New reference. # Return value: New reference.
# Identical to PyString_FromFormat() except that it takes exactly two arguments. # Identical to PyString_FromFormat() except that it takes exactly two arguments.
Py_ssize_t PyString_Size(object string) Py_ssize_t PyString_Size(object string) except -1
# Return the length of the string in string object string. # Return the length of the string in string object string.
Py_ssize_t PyString_GET_SIZE(object string) Py_ssize_t PyString_GET_SIZE(object string)
......
...@@ -24,7 +24,7 @@ cdef extern from "Python.h": ...@@ -24,7 +24,7 @@ cdef extern from "Python.h":
# pointing to Python objects. "PyTuple_Pack(2, a, b)" is # pointing to Python objects. "PyTuple_Pack(2, a, b)" is
# equivalent to "Py_BuildValue("(OO)", a, b)". # equivalent to "Py_BuildValue("(OO)", a, b)".
int PyTuple_Size(object p) int PyTuple_Size(object p) except -1
# Take a pointer to a tuple object, and return the size of that tuple. # Take a pointer to a tuple object, and return the size of that tuple.
int PyTuple_GET_SIZE(object p) int PyTuple_GET_SIZE(object p)
......
...@@ -93,10 +93,10 @@ cdef extern from *: ...@@ -93,10 +93,10 @@ cdef extern from *:
# Return a read-only pointer to the Unicode object's internal # Return a read-only pointer to the Unicode object's internal
# Py_UNICODE buffer, NULL if unicode is not a Unicode object. # Py_UNICODE buffer, NULL if unicode is not a Unicode object.
Py_UNICODE* PyUnicode_AsUnicode(object o) Py_UNICODE* PyUnicode_AsUnicode(object o) except NULL
# Return the length of the Unicode object. # Return the length of the Unicode object.
Py_ssize_t PyUnicode_GetSize(object o) Py_ssize_t PyUnicode_GetSize(object o) except -1
# Coerce an encoded object obj to an Unicode object and return a # Coerce an encoded object obj to an Unicode object and return a
# reference with incremented refcount. # reference with incremented refcount.
......
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