本文整理汇总了C++中PyIndex_Check函数的典型用法代码示例。如果您正苦于以下问题:C++ PyIndex_Check函数的具体用法?C++ PyIndex_Check怎么用?C++ PyIndex_Check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyIndex_Check函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: igraphmodule_EdgeSeq_get_attribute_values_mapping
PyObject* igraphmodule_EdgeSeq_get_attribute_values_mapping(igraphmodule_EdgeSeqObject *self, PyObject *o) {
Py_ssize_t index;
/* Handle integer indices according to the sequence protocol */
if (PyIndex_Check(o)) {
index = PyNumber_AsSsize_t(o, 0);
return igraphmodule_EdgeSeq_sq_item(self, index);
}
/* Handle strings according to the mapping protocol */
if (PyBaseString_Check(o))
return igraphmodule_EdgeSeq_get_attribute_values(self, o);
/* Handle iterables and slices by calling the select() method */
if (PySlice_Check(o) || PyObject_HasAttrString(o, "__iter__")) {
PyObject *result, *args;
args = Py_BuildValue("(O)", o);
if (!args)
return NULL;
result = igraphmodule_EdgeSeq_select(self, args);
Py_DECREF(args);
return result;
}
/* Handle everything else according to the mapping protocol */
return igraphmodule_EdgeSeq_get_attribute_values(self, o);
}
开发者ID:bravery,项目名称:python-igraph,代码行数:27,代码来源:edgeseqobject.c
示例2: CONVERT_TO_INDEX
NUITKA_MAY_BE_UNUSED static Py_ssize_t CONVERT_TO_INDEX( PyObject *value )
{
assertObject( value );
#if PYTHON_VERSION < 300
if ( PyInt_Check( value ) )
{
return PyInt_AS_LONG( value );
}
else
#endif
if ( PyIndex_Check( value ) )
{
Py_ssize_t result = PyNumber_AsSsize_t( value, NULL );
if (unlikely( result == -1 ))
{
THROW_IF_ERROR_OCCURED();
}
return result;
}
else
{
PyErr_Format( PyExc_TypeError, "slice indices must be integers or None or have an __index__ method" );
throw PythonException();
}
}
开发者ID:ballacky13,项目名称:Nuitka,代码行数:28,代码来源:indexes.hpp
示例3: tupleMul
Box* tupleMul(BoxedTuple* self, Box* rhs) {
Py_ssize_t n;
if (PyIndex_Check(rhs)) {
n = PyNumber_AsSsize_t(rhs, PyExc_OverflowError);
if (n == -1 && PyErr_Occurred())
throwCAPIException();
} else {
raiseExcHelper(TypeError, "can't multiply sequence by non-int of type '%s'", getTypeName(rhs));
}
int s = self->size();
if (n < 0)
n = 0;
if ((s == 0 || n == 1) && PyTuple_CheckExact(self)) {
return self;
} else {
BoxedTuple* rtn = BoxedTuple::create(n * s);
int rtn_i = 0;
for (int i = 0; i < n; ++i) {
memmove(&rtn->elts[rtn_i], &self->elts[0], sizeof(Box*) * s);
rtn_i += s;
}
return rtn;
}
}
开发者ID:jmgc,项目名称:pyston,代码行数:27,代码来源:tuple.cpp
示例4: Affine_subscript
static PyObject *
Affine_subscript(polypaths_planar_overrideAffineObject *self, PyObject *item)
{
Py_ssize_t i;
PyObject *t, *s;
assert(polypaths_planar_overrideAffine_Check(self));
if (PyIndex_Check(item)) {
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred()) {
return NULL;
}
if (i < 0) {
i += Affine_len((PyObject *)self);
}
return Affine_getitem(self, i);
} else if (PySlice_Check(item)) {
/* We cheat a bit here by constructing a tuple from ourself and
slicing that, which is convenient since slicing a transform
results in a tuple. Not the most efficient, but I don't expect
transform slicing to be a common, performance sensitive operation
*/
t = PySequence_Tuple((PyObject *)self);
if (t == NULL) {
return NULL;
}
s = PyObject_GetItem(t, item);
Py_DECREF(t);
return s;
}
PyErr_Format(PyExc_TypeError,
"Affine indices must be integers, not %.200s",
Py_TYPE(item)->tp_name);
return NULL;
}
开发者ID:apolcyn,项目名称:polypaths_planar_override,代码行数:35,代码来源:ctransform.c
示例5: BGE_PROXY_REF
static PyObject *KX_PythonSeq_subscript(PyObject *self, PyObject *key)
{
PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base);
if (self_plus==NULL) {
PyErr_SetString(PyExc_SystemError, "val = seq[key], KX_PythonSeq: " BGE_PROXY_ERROR_MSG);
return NULL;
}
if (PyIndex_Check(key)) {
return KX_PythonSeq_getIndex(self, PyLong_AsSsize_t(key));
}
else if ( PyUnicode_Check(key) ) {
const char *name = _PyUnicode_AsString(key);
PyObjectPlus *ret = KX_PythonSeq_subscript__internal(self, name);
if (ret) {
return ret->GetProxy();
} else {
PyErr_Format( PyExc_KeyError, "requested item \"%s\" does not exist", name);
return NULL;
}
}
else {
PyErr_SetString( PyExc_TypeError, "expected a string or an index" );
return NULL;
}
}
开发者ID:244xiao,项目名称:blender,代码行数:28,代码来源:KX_PythonSeq.cpp
示例6: Color_ass_subscript
static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *value)
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return -1;
if (i < 0)
i += COLOR_SIZE;
return Color_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx((void *)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
return -1;
if (step == 1)
return Color_ass_slice(self, start, stop, value);
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with color");
return -1;
}
}
else {
PyErr_Format(PyExc_TypeError,
"color indices must be integers, not %.200s",
Py_TYPE(item)->tp_name);
return -1;
}
}
开发者ID:mik0001,项目名称:Blender,代码行数:31,代码来源:mathutils_Color.c
示例7: PyFloat_FromDouble
static PyObject *bpy_bmdeformvert_subscript(BPy_BMDeformVert *self, PyObject *key)
{
if (PyIndex_Check(key)) {
int i;
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (i == -1 && PyErr_Occurred()) {
return NULL;
}
else {
MDeformWeight *dw = defvert_find_index(self->data, i);
if (dw == NULL) {
PyErr_SetString(PyExc_KeyError, "BMDeformVert[key] = x: "
"key not found");
return NULL;
}
else {
return PyFloat_FromDouble(dw->weight);
}
}
}
else {
PyErr_Format(PyExc_TypeError,
"BMDeformVert keys must be integers, not %.200s",
Py_TYPE(key)->tp_name);
return NULL;
}
}
开发者ID:wchargin,项目名称:blender,代码行数:28,代码来源:bmesh_py_types_meshdata.c
示例8: PyPointlessVector_check_index
static int PyPointlessVector_check_index(PyPointlessVector* self, PyObject* item, Py_ssize_t* i)
{
// if this is not an index: throw an exception
if (!PyIndex_Check(item)) {
PyErr_Format(PyExc_TypeError, "PointlessVector: integer indexes please, got <%s>\n", item->ob_type->tp_name);
return 0;
}
// if index value is not an integer: throw an exception
*i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (*i == -1 && PyErr_Occurred())
return 0;
// if index is negative, it is relative to vector end
if (*i < 0)
*i += PyPointlessVector_length(self);
// if it is out of bounds: throw an exception
if (!(0 <= *i && *i < PyPointlessVector_length(self))) {
PyErr_SetString(PyExc_IndexError, "index is out of bounds");
return 0;
}
return 1;
}
开发者ID:dohop,项目名称:py-pointless,代码行数:26,代码来源:pointless_vector.c
示例9: if
static PyObject *t_sequence_map_get(t_sequence* self, PyObject *item)
{
PyObject *value;
if (PyIndex_Check(item))
{
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
value = t_sequence_seq_get(self, i);
}
else if ((!(self->itemvalue.flags & V_PURE)) ||
(!((self->sequence->ob_type->tp_as_mapping &&
self->sequence->ob_type->tp_as_mapping->mp_subscript) ||
(PyObject_HasAttr(self->sequence, __getitem___NAME)))))
{
int size = PySequence_Size(self->sequence);
PyObject *values;
if (size < 0)
return NULL;
values = t_sequence_seq_getslice(self, 0, size);
if (!values)
return NULL;
value = PyObject_GetItem(values, item);
Py_DECREF(values);
}
else
value = PyObject_GetItem(self->sequence, item);
return value;
}
开发者ID:HackLinux,项目名称:chandler,代码行数:35,代码来源:sequence.c
示例10:
static PyObject *SEQUENCE_REPEAT( ssizeargfunc repeatfunc, PyObject *seq, PyObject *n )
{
if (unlikely( !PyIndex_Check( n ) ))
{
PyErr_Format(
PyExc_TypeError,
"can't multiply sequence by non-int of type '%s'",
Py_TYPE( n )->tp_name
);
return NULL;
}
PyObject *index_value = PyNumber_Index( n );
if (unlikely( index_value == NULL ))
{
return NULL;
}
/* We're done if PyInt_AsSsize_t() returns without error. */
#if PYTHON_VERSION < 300
Py_ssize_t count = PyInt_AsSsize_t( index_value );
#else
Py_ssize_t count = PyLong_AsSsize_t( index_value );
#endif
Py_DECREF( index_value );
if (unlikely( count == -1 )) // Note: -1 is an unlikely repetition count
{
PyObject *exception = GET_ERROR_OCCURRED();
if (unlikely( exception ))
{
if ( !EXCEPTION_MATCH_BOOL_SINGLE( exception, PyExc_OverflowError ) )
{
return NULL;
}
PyErr_Format(
PyExc_OverflowError,
"cannot fit '%s' into an index-sized integer",
Py_TYPE( n )->tp_name
);
return NULL;
}
}
PyObject *result = (*repeatfunc)( seq, count );
if (unlikely( result == NULL ))
{
return NULL;
}
return result;
}
开发者ID:gitter-badger,项目名称:Nuitka,代码行数:59,代码来源:operations.hpp
示例11: sipArray_ass_subscript
/*
* Implement mapping assignment sub-script for the type.
*/
static int sipArray_ass_subscript(PyObject *self, PyObject *key,
PyObject *value)
{
sipArrayObject *array = (sipArrayObject *)self;
SIP_SSIZE_T start, len;
void *value_data;
if (check_writable(array) < 0)
return -1;
if (PyIndex_Check(key))
{
start = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (start == -1 && PyErr_Occurred())
return -1;
if (start < 0)
start += array->len;
if (check_index(array, start) < 0)
return -1;
if ((value_data = get_value(array, value)) == NULL)
return -1;
len = 1;
}
else if (PySlice_Check(key))
{
Py_ssize_t stop, step;
if (sipConvertFromSliceObject(key, array->len, &start, &stop, &step, &len) < 0)
return -1;
if (step != 1)
{
PyErr_SetNone(PyExc_NotImplementedError);
return -1;
}
if ((value_data = get_slice(array, value, len)) == NULL)
return -1;
}
else
{
bad_key(key);
return -1;
}
memmove(element(array, start), value_data, len * array->stride);
return 0;
}
开发者ID:Narengowda,项目名称:web-mouse,代码行数:58,代码来源:array.c
示例12: tuplesubscript
static PyObject*
tuplesubscript(PyTupleObject* self, PyObject* item)
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
if (i < 0)
i += PyTuple_GET_SIZE(self);
return tupleitem(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength, cur, i;
PyObject* result;
PyObject* it;
PyObject **src, **dest;
if (PySlice_GetIndicesEx(item,
PyTuple_GET_SIZE(self),
&start, &stop, &step, &slicelength) < 0) {
return NULL;
}
if (slicelength <= 0) {
return PyTuple_New(0);
}
else if (start == 0 && step == 1 &&
slicelength == PyTuple_GET_SIZE(self) &&
PyTuple_CheckExact(self)) {
Py_INCREF(self);
return (PyObject *)self;
}
else {
result = PyTuple_New(slicelength);
if (!result) return NULL;
src = self->ob_item;
dest = ((PyTupleObject *)result)->ob_item;
for (cur = start, i = 0; i < slicelength;
cur += step, i++) {
it = src[cur];
Py_INCREF(it);
dest[i] = it;
}
return result;
}
}
else {
PyErr_Format(PyExc_TypeError,
"tuple indices must be integers, not %.200s",
Py_TYPE(item)->tp_name);
return NULL;
}
}
开发者ID:IgnusIndia,项目名称:pythonexperiment,代码行数:55,代码来源:tupleobject.c
示例13: bpy_bmlayercollection_subscript_str
static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, PyObject *key)
{
/* don't need error check here */
if (PyUnicode_Check(key)) {
return bpy_bmlayercollection_subscript_str(self, _PyUnicode_AsString(key));
}
else if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
return bpy_bmlayercollection_subscript_int(self, i);
}
else if (PySlice_Check(key)) {
PySliceObject *key_slice = (PySliceObject *)key;
Py_ssize_t step = 1;
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
return NULL;
}
else if (step != 1) {
PyErr_SetString(PyExc_TypeError,
"BMLayerCollection[slice]: slice steps not supported");
return NULL;
}
else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
return bpy_bmlayercollection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
}
else {
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
if (start < 0 || stop < 0) {
/* only get the length for negative values */
Py_ssize_t len = bpy_bmlayercollection_length(self);
if (start < 0) start += len;
if (stop < 0) stop += len;
}
if (stop - start <= 0) {
return PyTuple_New(0);
}
else {
return bpy_bmlayercollection_subscript_slice(self, start, stop);
}
}
}
else {
PyErr_SetString(PyExc_AttributeError,
"BMLayerCollection[key]: invalid key, key must be an int");
return NULL;
}
}
开发者ID:wchargin,项目名称:blender,代码行数:55,代码来源:bmesh_py_types_customdata.c
示例14: buffer_subscript
static PyObject *
buffer_subscript(PyBufferObject *self, PyObject *item)
{
void *p;
Py_ssize_t size;
if (!get_buf(self, &p, &size, ANY_BUFFER))
return NULL;
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
if (i < 0)
i += size;
return buffer_item(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength, cur, i;
if (PySlice_GetIndicesEx((PySliceObject*)item, size,
&start, &stop, &step, &slicelength) < 0) {
return NULL;
}
if (slicelength <= 0)
return PyString_FromStringAndSize("", 0);
else if (step == 1)
return PyString_FromStringAndSize((char *)p + start,
stop - start);
else {
PyObject *result;
char *source_buf = (char *)p;
char *result_buf = (char *)PyMem_Malloc(slicelength);
if (result_buf == NULL)
return PyErr_NoMemory();
for (cur = start, i = 0; i < slicelength;
cur += step, i++) {
result_buf[i] = source_buf[cur];
}
result = PyString_FromStringAndSize(result_buf,
slicelength);
PyMem_Free(result_buf);
return result;
}
}
else {
PyErr_SetString(PyExc_TypeError,
"sequence index must be integer");
return NULL;
}
}
开发者ID:756613351,项目名称:python-source-code,代码行数:54,代码来源:bufferobject.c
示例15:
static PyObject *bserobj_getattrro(PyObject *o, PyObject *name) {
bserObject *obj = (bserObject*)o;
Py_ssize_t i, n;
PyObject *name_bytes = NULL;
PyObject *ret = NULL;
const char *namestr;
if (PyIndex_Check(name)) {
i = PyNumber_AsSsize_t(name, PyExc_IndexError);
if (i == -1 && PyErr_Occurred()) {
goto bail;
}
ret = PySequence_GetItem(obj->values, i);
goto bail;
}
// We can be passed in Unicode objects here -- we don't support anything other
// than UTF-8 for keys.
if (PyUnicode_Check(name)) {
name_bytes = PyUnicode_AsUTF8String(name);
if (name_bytes == NULL) {
goto bail;
}
namestr = PyBytes_AsString(name_bytes);
} else {
namestr = PyBytes_AsString(name);
}
if (namestr == NULL) {
goto bail;
}
// hack^Wfeature to allow mercurial to use "st_size" to reference "size"
if (!strncmp(namestr, "st_", 3)) {
namestr += 3;
}
n = PyTuple_GET_SIZE(obj->keys);
for (i = 0; i < n; i++) {
const char *item_name = NULL;
PyObject *key = PyTuple_GET_ITEM(obj->keys, i);
item_name = PyBytes_AsString(key);
if (!strcmp(item_name, namestr)) {
ret = PySequence_GetItem(obj->values, i);
goto bail;
}
}
PyErr_Format(PyExc_AttributeError,
"bserobject has no attribute '%.400s'", namestr);
bail:
Py_XDECREF(name_bytes);
return ret;
}
开发者ID:Jerry-goodboy,项目名称:watchman,代码行数:54,代码来源:bser.c
示例16: mmap_subscript
static PyObject *
mmap_subscript(mmap_object *self, PyObject *item)
{
CHECK_VALID(NULL);
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
if (i < 0)
i += self->size;
if (i < 0 || i >= self->size) {
PyErr_SetString(PyExc_IndexError,
"mmap index out of range");
return NULL;
}
return PyLong_FromLong(Py_CHARMASK(self->data[i]));
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelen;
if (PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelen = PySlice_AdjustIndices(self->size, &start, &stop, step);
if (slicelen <= 0)
return PyBytes_FromStringAndSize("", 0);
else if (step == 1)
return PyBytes_FromStringAndSize(self->data + start,
slicelen);
else {
char *result_buf = (char *)PyMem_Malloc(slicelen);
Py_ssize_t cur, i;
PyObject *result;
if (result_buf == NULL)
return PyErr_NoMemory();
for (cur = start, i = 0; i < slicelen;
cur += step, i++) {
result_buf[i] = self->data[cur];
}
result = PyBytes_FromStringAndSize(result_buf,
slicelen);
PyMem_Free(result_buf);
return result;
}
}
else {
PyErr_SetString(PyExc_TypeError,
"mmap indices must be integers");
return NULL;
}
}
开发者ID:1st1,项目名称:cpython,代码行数:53,代码来源:mmapmodule.c
示例17: GMPy_XMPZ_Method_SubScript
static PyObject *
GMPy_XMPZ_Method_SubScript(XMPZ_Object* self, PyObject* item)
{
CTXT_Object *context = NULL;
CHECK_CONTEXT(context);
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyIntOrLong_AsSsize_t(item);
if (i == -1 && PyErr_Occurred()) {
INDEX_ERROR("argument too large to be converted to an index");
return NULL;
}
if (i < 0) {
i += mpz_sizeinbase(self->z, 2);
}
return PyIntOrLong_FromLong(mpz_tstbit(self->z, i));
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength, cur, i;
MPZ_Object *result;
#if PY_VERSION_HEX > 0x030200A4
if (PySlice_GetIndicesEx(item,
#else
if (PySlice_GetIndicesEx((PySliceObject*)item,
#endif
mpz_sizeinbase(self->z, 2),
&start, &stop, &step, &slicelength) < 0) {
return NULL;
}
if ((step < 0 && start < stop) || (step > 0 && start > stop)) {
stop = start;
}
if (!(result = GMPy_MPZ_New(context))) {
return NULL;
}
mpz_set_ui(result->z, 0);
if (slicelength > 0) {
for (cur = start, i = 0; i < slicelength; cur += step, i++) {
if (mpz_tstbit(self->z, cur)) {
mpz_setbit(result->z, i);
}
}
}
return (PyObject*)result;
}
else {
开发者ID:fuzzylogician,项目名称:gmpy,代码行数:53,代码来源:gmpy2_xmpz_misc.c
示例18: Row_subscript
static PyObject* Row_subscript(PyObject* o, PyObject* key)
{
Row* row = (Row*)o;
if (PyIndex_Check(key))
{
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return 0;
if (i < 0)
i += row->cValues;
if (i < 0 || i >= row->cValues)
return PyErr_Format(PyExc_IndexError, "row index out of range index=%d len=%d", (int)i, (int)row->cValues);
Py_INCREF(row->apValues[i]);
return row->apValues[i];
}
if (PySlice_Check(key))
{
Py_ssize_t start, stop, step, slicelength;
#if PY_VERSION_HEX >= 0x03020000
if (PySlice_GetIndicesEx(key, row->cValues, &start, &stop, &step, &slicelength) < 0)
return 0;
#else
if (PySlice_GetIndicesEx((PySliceObject*)key, row->cValues, &start, &stop, &step, &slicelength) < 0)
return 0;
#endif
if (slicelength <= 0)
return PyTuple_New(0);
if (start == 0 && step == 1 && slicelength == row->cValues)
{
Py_INCREF(o);
return o;
}
Object result(PyTuple_New(slicelength));
if (!result)
return 0;
for (Py_ssize_t i = 0, index = start; i < slicelength; i++, index += step)
{
PyTuple_SET_ITEM(result.Get(), i, row->apValues[index]);
Py_INCREF(row->apValues[index]);
}
return result.Detach();
}
return PyErr_Format(PyExc_TypeError, "row indices must be integers, not %.200s", Py_TYPE(key)->tp_name);
}
开发者ID:Bobspadger,项目名称:pyodbc,代码行数:52,代码来源:row.cpp
示例19: tupleGetitem
Box* tupleGetitem(BoxedTuple* self, Box* slice) {
assert(self->cls == tuple_cls);
if (PyIndex_Check(slice)) {
Py_ssize_t i = PyNumber_AsSsize_t(slice, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
throwCAPIException();
return tupleGetitemUnboxed(self, i);
} else if (slice->cls == slice_cls)
return tupleGetitemSlice(self, static_cast<BoxedSlice*>(slice));
else
raiseExcHelper(TypeError, "tuple indices must be integers, not %s", getTypeName(slice));
}
开发者ID:jmgc,项目名称:pyston,代码行数:13,代码来源:tuple.cpp
示例20: evaluate_slice_index
static PyObject*
evaluate_slice_index(PyObject *v)
{
if (PyIndex_Check(v)) {
return PyNumber_Index(v);
}
else {
PyErr_SetString(PyExc_TypeError,
"slice indices must be integers or "
"None or have an __index__ method");
return NULL;
}
}
开发者ID:adrian17,项目名称:cpython,代码行数:13,代码来源:sliceobject.c
注:本文中的PyIndex_Check函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论