本文整理汇总了C++中PyErr_BadInternalCall函数的典型用法代码示例。如果您正苦于以下问题:C++ PyErr_BadInternalCall函数的具体用法?C++ PyErr_BadInternalCall怎么用?C++ PyErr_BadInternalCall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyErr_BadInternalCall函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Validator_AddElementType
int Validator_AddElementType(PyObject *self, PyObject *element)
{
if (!Validator_Check(self) && !ElementType_Check(element)) {
PyErr_BadInternalCall();
return -1;
}
/* already defined, keep first decl */
if (PyDict_GetItem(Validator_Elements(self), ElementType_GET_NAME(element)))
return 0;
/* add the ElementType to our set of legal elements */
if (PyDict_SetItem(Validator_Elements(self), ElementType_GET_NAME(element),
element) < 0) {
return -1;
}
return 1;
}
开发者ID:H1d3r,项目名称:binary_blobs,代码行数:19,代码来源:content_model.c
示例17: create_init_thread
/* Create a platform-independent initialisation thread.
On success it returns 0 and sets the thread parameter,
on failure returns -1.
*/
int
create_init_thread(void *param, ldap_conndata_t *info, XTHREAD *thread) {
int rc = 0;
ldapInitThreadData *data = (ldapInitThreadData *)param;
DEBUG("create_init_thread (ld:%p, info:%p, thread:%lu)", param, info, *thread);
#ifdef WIN32
*thread = CreateThread(NULL, 0, ldap_init_thread_func, (void *)data, 0, NULL);
if (*thread == NULL) rc = -1;
#else
data->mux = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
if (data->mux == NULL) {
PyErr_NoMemory();
return -1;
}
rc = pthread_mutex_init(data->mux, NULL);
if (rc != 0) {
PyErr_BadInternalCall();
return -1;
}
pthread_mutex_lock(data->mux);
data->flag = 0;
#ifdef HAVE_KRB5
data->info = info;
if (data->info->mech != NULL && (strcmp("GSSAPI", data->info->mech) == 0 ||
strcmp("GSS-SPNEGO", data->info->mech) == 0)
&& data->info->realm != NULL && strlen(data->info->realm) != 0
&& data->info->authcid != NULL && strlen(data->info->authcid) != 0) {
data->info->request_tgt = 1;
rc = krb5_init_context(&(data->info->ctx));
if (rc != 0) return -1;
}
#endif
pthread_mutex_unlock(data->mux);
rc = pthread_create(thread, NULL, ldap_init_thread_func, data);
#endif
if (rc != 0) return -1;
return 0;
}
开发者ID:Noirello,项目名称:bonsai,代码行数:46,代码来源:ldap-xplat.c
示例18: Validator_EndElement
int Validator_EndElement(PyObject *self)
{
Context *context;
int valid;
if (!Validator_Check(self)) {
PyErr_BadInternalCall();
return -1;
}
#ifdef DEBUG_VALIDATION
fprintf(stderr, "Validator_EndElement()");
#endif
context = Validator_Context(self);
/* context may be NULL if we never encounter a declared element */
if (context != NULL) {
#ifdef DEBUG_VALIDATION
fprintf(stderr, " for ");
if (context->element) {
PyObject_Print(ElementType_GET_NAME(context->element), stderr, 0);
} else {
fprintf(stderr, "undeclared");
}
fprintf(stderr, " element\n");
#endif
/* make sure that we are in the final state */
valid = Validator_ValidateEvent(self, final_event);
/* switch the active context to the following one */
Validator_Context(self) = context->next;
/* move this one to the free list */
context->next = Validator_FreeContext(self);
Validator_FreeContext(self) = context;
} else {
valid = 1;
}
return valid;
}
开发者ID:H1d3r,项目名称:binary_blobs,代码行数:42,代码来源:content_model.c
示例19: binding
/* Poll the answer of the separate thread that runs the binding process.
Returns NULL in case of error, Py_None for timeout, and the LDAPConnection
object if successfully finished the binding. */
static PyObject *
binding(LDAPConnectIter *self) {
int rc;
if (self->bind_inprogress == 0) {
/* First call of bind. */
rc = LDAP_bind(self->conn->ld, self->info, NULL, &(self->message_id));
if (rc != LDAP_SUCCESS) {
set_exception(self->conn->ld, rc);
return NULL;
}
self->bind_inprogress = 1;
Py_RETURN_NONE;
} else {
if (self->async) {
rc = WaitForSingleObject(self->info->thread, 10);
} else {
rc = WaitForSingleObject(self->info->thread, INFINITE);
}
switch (rc) {
case WAIT_TIMEOUT:
Py_RETURN_NONE;
case WAIT_OBJECT_0:
GetExitCodeThread(self->info->thread, &rc);
CloseHandle(self->info->thread);
if (rc != LDAP_SUCCESS) {
/* The ldap_connect is failed. Set a Python error. */
set_exception(self->conn->ld, rc);
return NULL;
}
/* The binding is successfully finished. */
self->bind_inprogress = 0;
self->conn->closed = 0;
Py_INCREF((PyObject *)self->conn);
return (PyObject *)self->conn;
default:
/* The thread is failed. */
PyErr_BadInternalCall();
return NULL;
}
}
}
开发者ID:matepeter90,项目名称:PyLDAP,代码行数:45,代码来源:ldapconnectiter.c
示例20: PyFunction_SetKwDefaults
int
PyFunction_SetKwDefaults(PyObject *op, PyObject *defaults)
{
if (!PyFunction_Check(op)) {
PyErr_BadInternalCall();
return -1;
}
if (defaults == Py_None)
defaults = NULL;
else if (defaults && PyDict_Check(defaults)) {
Py_INCREF(defaults);
}
else {
PyErr_SetString(PyExc_SystemError,
"non-dict keyword only default args");
return -1;
}
Py_SETREF(((PyFunctionObject *)op)->func_kwdefaults, defaults);
return 0;
}
开发者ID:cbiggles,项目名称:cpython,代码行数:20,代码来源:funcobject.c
注:本文中的PyErr_BadInternalCall函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论