当前位置: 首页>>代码示例>>C++>>正文


C++ PyErr_BadInternalCall函数代码示例

本文整理汇总了C++中PyErr_BadInternalCall函数的典型用法代码示例。如果您正苦于以下问题:C++ PyErr_BadInternalCall函数的具体用法?C++ PyErr_BadInternalCall怎么用?C++ PyErr_BadInternalCall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PyErr_BadInternalCall函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exception

/* Compare v to w.  Return
   -1 if v <  w or exception (PyErr_Occurred() true in latter case).
    0 if v == w.
    1 if v > w.
   XXX The docs (C API manual) say the return value is undefined in case
   XXX of error.
*/
int
PyObject_Compare(PyObject *v, PyObject *w)
{
	int result;

	if (v == NULL || w == NULL) {
		PyErr_BadInternalCall();
		return -1;
	}
	if (v == w)
		return 0;
	if (Py_EnterRecursiveCall(" in cmp"))
		return -1;
	result = do_cmp(v, w);
	Py_LeaveRecursiveCall();
	return result < 0 ? -1 : result;
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:24,代码来源:object.c

示例2: path_iter

static PyObject *
path_iter(PyObject *pypath) {
  PycairoPathiter *it;

  if (!PyObject_TypeCheck (pypath, &PycairoPath_Type)) {
    PyErr_BadInternalCall();
    return NULL;
  }
  it = PyObject_New(PycairoPathiter, &PycairoPathiter_Type);
  if (it == NULL)
    return NULL;

  it->index = 0;
  Py_INCREF(pypath);
  it->pypath = (PycairoPath *)pypath;
  return (PyObject *) it;
}
开发者ID:Lichtavat,项目名称:TCAX,代码行数:17,代码来源:path.c

示例3: transit_event

static int transit_event(PyObject *self, PyObject *event, int save)
{
  Context *context;
  PyObject *state;

  if (!Validator_Check(self)) {
    PyErr_BadInternalCall();
    return -1;
  }

#ifdef DEBUG_VALIDATION
  fprintf(stderr, "Validator_ValidateEvent(event=");
  PyObject_Print(event, stderr, 0);
  fprintf(stderr, ")\n");
#endif

  context = Validator_Context(self);
  /* context may be NULL if we never encounter a declared element */
  if (context != NULL) {
    /* check that this element is allowed here */
    /* context->state will be NULL for an ANY content model */
    if (context->state != NULL) {
      state = PyDict_GetItem(context->state, event);
      if (state == NULL) {
        /* element not allowed here */
#ifdef DEBUG_VALIDATION
        fprintf(stderr, "  Event not allowed on ");
        if (context->element) {
          PyObject_Print(ElementType_GET_NAME(context->element), stderr, 0);
        } else {
          fprintf(stderr, " undeclared");
        }
        fprintf(stderr, " element.\n");
#endif
        return 0;
      }
      if (save) {
        /* save the state for next time */
        context->state = state;
      }
    }
  }

  return 1;
}
开发者ID:H1d3r,项目名称:binary_blobs,代码行数:45,代码来源:content_model.c

示例4: tuple_iter

static PyObject *
tuple_iter(PyObject *seq)
{
    tupleiterobject *it;

    if (!PyTuple_Check(seq)) {
        PyErr_BadInternalCall();
        return NULL;
    }
    it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type);
    if (it == NULL)
        return NULL;
    it->it_index = 0;
    Py_INCREF(seq);
    it->it_seq = (PyTupleObject *)seq;
    _PyObject_GC_TRACK(it);
    return (PyObject *)it;
}
开发者ID:IgnusIndia,项目名称:pythonexperiment,代码行数:18,代码来源:tupleobject.c

示例5: range_iter

static PyObject *
range_iter(PyObject *seq)
{
	rangeiterobject *it;

	if (!PyRange_Check(seq)) {
		PyErr_BadInternalCall();
		return NULL;
	}
	it = PyObject_New(rangeiterobject, &Pyrangeiter_Type);
	if (it == NULL)
		return NULL;
	it->index = 0;
	it->start = ((rangeobject *)seq)->start;
	it->step = ((rangeobject *)seq)->step;
	it->len = ((rangeobject *)seq)->len;
	return (PyObject *)it;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:18,代码来源:rangeobject.c

示例6: PySeqIter_New

PyObject *
PySeqIter_New(PyObject *seq)
{
    seqiterobject *it;

    if (!PySequence_Check(seq)) {
        PyErr_BadInternalCall();
        return NULL;
    }
    it = PyObject_GC_New(seqiterobject, &PySeqIter_Type);
    if (it == NULL)
        return NULL;
    it->it_index = 0;
    Py_INCREF(seq);
    it->it_seq = seq;
    _PyObject_GC_TRACK(it);
    return (PyObject *)it;
}
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:18,代码来源:iterobject.c

示例7: record_iter

static PyObject *
record_iter(PyObject *seq)
{
    ApgRecordIterObject *it;

    if (!ApgRecord_CheckExact(seq)) {
        PyErr_BadInternalCall();
        return NULL;
    }
    it = PyObject_GC_New(ApgRecordIterObject, &ApgRecordIter_Type);
    if (it == NULL)
        return NULL;
    it->it_index = 0;
    Py_INCREF(seq);
    it->it_seq = (ApgRecordObject *)seq;
    _PyObject_GC_TRACK(it);
    return (PyObject *)it;
}
开发者ID:datnamer,项目名称:asyncpg,代码行数:18,代码来源:recordobj.c

示例8: PyLong_AsUnsignedLongLong

extern "C" unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject* vv) noexcept {
    unsigned PY_LONG_LONG bytes;
    int one = 1;
    int res;

    if (vv == NULL || !PyLong_Check(vv)) {
        PyErr_BadInternalCall();
        return (unsigned PY_LONG_LONG) - 1;
    }

    res = _PyLong_AsByteArray((PyLongObject*)vv, (unsigned char*)&bytes, SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0);

    /* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
    if (res < 0)
        return (unsigned PY_LONG_LONG)res;
    else
        return bytes;
}
开发者ID:lameiro,项目名称:pyston,代码行数:18,代码来源:long.cpp

示例9: XsltRoot_AppendChild

int XsltRoot_AppendChild(XsltRootObject *self, XsltNodeObject *child)
{
  PyObject *temp;

  if (!XsltRoot_Check(self) || !XsltNode_Check(child)) {
    PyErr_BadInternalCall();
    return -1;
  }

  /* Make the node our only child */
  temp = self->stylesheet;
  Py_INCREF(child);
  self->stylesheet = (PyObject *) child;
  Py_DECREF(temp);

  /* Set its parent link */
  return XsltNode_Link(XsltNode(self), child);
}
开发者ID:abed-hawa,项目名称:amara,代码行数:18,代码来源:xslt_root.c

示例10: PyLong_AsLongLong

extern "C" PY_LONG_LONG PyLong_AsLongLong(PyObject* vv) noexcept {
    PY_LONG_LONG bytes;
    int one = 1;
    int res;

    if (vv == NULL) {
        PyErr_BadInternalCall();
        return -1;
    }
    if (!PyLong_Check(vv)) {
        PyNumberMethods* nb;
        PyObject* io;
        if (PyInt_Check(vv))
            return (PY_LONG_LONG)PyInt_AsLong(vv);
        if ((nb = vv->cls->tp_as_number) == NULL || nb->nb_int == NULL) {
            PyErr_SetString(PyExc_TypeError, "an integer is required");
            return -1;
        }
        io = (*nb->nb_int)(vv);
        if (io == NULL)
            return -1;
        if (PyInt_Check(io)) {
            bytes = PyInt_AsLong(io);
            Py_DECREF(io);
            return bytes;
        }
        if (PyLong_Check(io)) {
            bytes = PyLong_AsLongLong(io);
            Py_DECREF(io);
            return bytes;
        }
        Py_DECREF(io);
        PyErr_SetString(PyExc_TypeError, "integer conversion failed");
        return -1;
    }

    res = _PyLong_AsByteArray((PyLongObject*)vv, (unsigned char*)&bytes, SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1);

    /* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
    if (res < 0)
        return (PY_LONG_LONG)-1;
    else
        return bytes;
}
开发者ID:lameiro,项目名称:pyston,代码行数:44,代码来源:long.cpp

示例11: _PyCode_GetExtra

int
_PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
{
    if (!PyCode_Check(code)) {
        PyErr_BadInternalCall();
        return -1;
    }

    PyCodeObject *o = (PyCodeObject*) code;
    _PyCodeObjectExtra *co_extra = (_PyCodeObjectExtra*) o->co_extra;

    if (co_extra == NULL || co_extra->ce_size <= index) {
        *extra = NULL;
        return 0;
    }

    *extra = co_extra->ce_extras[index];
    return 0;
}
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:19,代码来源:codeobject.c

示例12: PyPointlessSet_iter

static PyObject* PyPointlessSet_iter(PyObject* set)
{
	if (!PyPointlessSet_Check(set)) {
		PyErr_BadInternalCall();
		return 0;
	}

	PyPointlessSetIter* iter = PyObject_New(PyPointlessSetIter, &PyPointlessSetIterType);

	if (iter == 0)
		return 0;

	Py_INCREF(set);

	iter->set = (PyPointlessSet*)set;
	iter->iter_state = 0;

	return (PyObject*)iter;
}
开发者ID:dohopmas,项目名称:py-pointless,代码行数:19,代码来源:pointless_set.c

示例13: PyPointlessVector_iter

static PyObject* PyPointlessVector_iter(PyObject* vector)
{
	if (!PyPointlessVector_Check(vector)) {
		PyErr_BadInternalCall();
		return 0;
	}

	PyPointlessVectorIter* iter = PyObject_New(PyPointlessVectorIter, &PyPointlessVectorIterType);

	if (iter == 0)
		return 0;

	Py_INCREF(vector);

	iter->vector = (PyPointlessVector*)vector;
	iter->iter_state = 0;

	return (PyObject*)iter;
}
开发者ID:dohop,项目名称:py-pointless,代码行数:19,代码来源:pointless_vector.c

示例14: PyLong_AsLongAndOverflow

extern "C" long PyLong_AsLongAndOverflow(Box* vv, int* overflow) noexcept {
    // Ported from CPython; original comment:
    /* This version by Tim Peters */

    *overflow = 0;
    if (vv == NULL) {
        PyErr_BadInternalCall();
        return -1;
    }

    if (PyInt_Check(vv))
        return PyInt_AsLong(vv);

    if (!PyLong_Check(vv)) {
        PyNumberMethods* nb;
        nb = vv->cls->tp_as_number;
        if (nb == NULL || nb->nb_int == NULL) {
            PyErr_SetString(PyExc_TypeError, "an integer is required");
            return -1;
        }

        vv = (*nb->nb_int)(vv);
        if (vv == NULL)
            return -1;

        if (PyInt_Check(vv))
            return PyInt_AsLong(vv);

        if (!PyLong_Check(vv)) {
            PyErr_SetString(PyExc_TypeError, "nb_int should return int object");
            return -1;
        }
        // fallthrough: this has to be a long
    }

    BoxedLong* l = static_cast<BoxedLong*>(vv);
    if (mpz_fits_slong_p(l->n)) {
        return mpz_get_si(l->n);
    } else {
        *overflow = mpz_sgn(l->n);
        return -1;
    }
}
开发者ID:lameiro,项目名称:pyston,代码行数:43,代码来源:long.cpp

示例15: PyTuple_SetItem

int
PyTuple_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem)
{
    PyObject **p;
    if (!PyTuple_Check(op) || op->ob_refcnt != 1) {
        Py_XDECREF(newitem);
        PyErr_BadInternalCall();
        return -1;
    }
    if (i < 0 || i >= Py_SIZE(op)) {
        Py_XDECREF(newitem);
        PyErr_SetString(PyExc_IndexError,
                        "tuple assignment index out of range");
        return -1;
    }
    p = ((PyTupleObject *)op) -> ob_item + i;
    Py_XSETREF(*p, newitem);
    return 0;
}
开发者ID:CabbageHead-360,项目名称:cpython,代码行数:19,代码来源:tupleobject.c


注:本文中的PyErr_BadInternalCall函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。