• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PyErr_WriteUnraisable函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Struct_tp_dealloc

static void
Struct_tp_dealloc(PyObject *self)
{
    PyObject *et, *ev, *etb, *key;

    dbus_py_variant_level_clear(self);
    PyErr_Fetch(&et, &ev, &etb);

    key = PyLong_FromVoidPtr(self);
    if (key) {
        if (PyDict_GetItem(struct_signatures, key)) {
            if (PyDict_DelItem(struct_signatures, key) < 0) {
                /* should never happen */
                PyErr_WriteUnraisable(self);
            }
        }
        Py_CLEAR(key);
    }
    else {
        /* not enough memory to free all the memory... leak the signature,
         * there's not much else we could do here */
        PyErr_WriteUnraisable(self);
    }

    PyErr_Restore(et, ev, etb);
    (PyTuple_Type.tp_dealloc)(self);
}
开发者ID:smcv,项目名称:dbus-python,代码行数:27,代码来源:containers.c


示例2: __Pyx_WriteUnraisable

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#endif
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}
开发者ID:Huskyeder,项目名称:cython,代码行数:35,代码来源:Exceptions.c


示例3: _PyGC_Fini

void
_PyGC_Fini(void)
{
    if (!(debug & DEBUG_SAVEALL)
        && garbage != NULL && PyList_GET_SIZE(garbage) > 0) {
        char *message;
        if (debug & DEBUG_UNCOLLECTABLE)
            message = "gc: %zd uncollectable objects at " \
                "shutdown";
        else
            message = "gc: %zd uncollectable objects at " \
                "shutdown; use gc.set_debug(gc.DEBUG_UNCOLLECTABLE) to list them";
        if (PyErr_WarnFormat(PyExc_ResourceWarning, 0, message,
                             PyList_GET_SIZE(garbage)) < 0)
            PyErr_WriteUnraisable(NULL);
        if (debug & DEBUG_UNCOLLECTABLE) {
            PyObject *repr = NULL, *bytes = NULL;
            repr = PyObject_Repr(garbage);
            if (!repr || !(bytes = PyUnicode_EncodeFSDefault(repr)))
                PyErr_WriteUnraisable(garbage);
            else {
                PySys_WriteStderr(
                    "    %s\n",
                    PyBytes_AS_STRING(bytes)
                    );
            }
            Py_XDECREF(repr);
            Py_XDECREF(bytes);
        }
    }
}
开发者ID:d11,项目名称:rts,代码行数:31,代码来源:gcmodule.c


示例4: CallExternalTimer

static PY_LONG_LONG CallExternalTimer(ProfilerObject *pObj)
{
	PY_LONG_LONG result;
	PyObject *o = PyObject_Call(pObj->externalTimer, empty_tuple, NULL);
	if (o == NULL) {
		PyErr_WriteUnraisable(pObj->externalTimer);
		return 0;
	}
	if (pObj->externalTimerUnit > 0.0) {
		/* interpret the result as an integer that will be scaled
		   in profiler_getstats() */
		result = PyLong_AsLongLong(o);
	}
	else {
		/* interpret the result as a double measured in seconds.
		   As the profiler works with PY_LONG_LONG internally
		   we convert it to a large integer */
		double val = PyFloat_AsDouble(o);
		/* error handling delayed to the code below */
		result = (PY_LONG_LONG) (val * DOUBLE_TIMER_PRECISION);
	}
	Py_DECREF(o);
	if (PyErr_Occurred()) {
		PyErr_WriteUnraisable(pObj->externalTimer);
		return 0;
	}
	return result;
}
开发者ID:andrcmdr,项目名称:unladen-swallow,代码行数:28,代码来源:_lsprof.c


示例5: Call_GetClassObject

long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
	PyObject *mod, *func, *result;
	long retval;
	static PyObject *context;

	if (context == NULL)
		context = PyUnicode_InternFromString("_ctypes.DllGetClassObject");

	mod = PyImport_ImportModuleNoBlock("ctypes");
	if (!mod) {
		PyErr_WriteUnraisable(context ? context : Py_None);
		/* There has been a warning before about this already */
		return E_FAIL;
	}

	func = PyObject_GetAttrString(mod, "DllGetClassObject");
	Py_DECREF(mod);
	if (!func) {
		PyErr_WriteUnraisable(context ? context : Py_None);
		return E_FAIL;
	}

	{
		PyObject *py_rclsid = PyLong_FromVoidPtr((void *)rclsid);
		PyObject *py_riid = PyLong_FromVoidPtr((void *)riid);
		PyObject *py_ppv = PyLong_FromVoidPtr(ppv);
		if (!py_rclsid || !py_riid || !py_ppv) {
			Py_XDECREF(py_rclsid);
			Py_XDECREF(py_riid);
			Py_XDECREF(py_ppv);
			Py_DECREF(func);
			PyErr_WriteUnraisable(context ? context : Py_None);
			return E_FAIL;
		}
		result = PyObject_CallFunctionObjArgs(func,
						      py_rclsid,
						      py_riid,
						      py_ppv,
						      NULL);
		Py_DECREF(py_rclsid);
		Py_DECREF(py_riid);
		Py_DECREF(py_ppv);
	}
	Py_DECREF(func);
	if (!result) {
		PyErr_WriteUnraisable(context ? context : Py_None);
		return E_FAIL;
	}

	retval = PyLong_AsLong(result);
	if (PyErr_Occurred()) {
		PyErr_WriteUnraisable(context ? context : Py_None);
		retval = E_FAIL;
	}
	Py_DECREF(result);
	return retval;
}
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:58,代码来源:callbacks.c


示例6: query_cname_cb

static void
query_cname_cb(void *arg, int status,int timeouts, unsigned char *answer_buf, int answer_len)
{
    PyGILState_STATE gstate = PyGILState_Ensure();
    int parse_status;
    struct hostent *hostent = NULL;
    PyObject *dns_result, *errorno, *tmp, *result, *callback;

    callback = (PyObject *)arg;
    ASSERT(callback);

    if (status != ARES_SUCCESS) {
        errorno = PyInt_FromLong((long)status);
        dns_result = Py_None;
        Py_INCREF(Py_None);
        goto callback;
    }

    parse_status = ares_parse_a_reply(answer_buf, answer_len, &hostent, NULL, NULL);
    if (parse_status != ARES_SUCCESS) {
        errorno = PyInt_FromLong((long)parse_status);
        dns_result = Py_None;
        Py_INCREF(Py_None);
        goto callback;
    }

    dns_result = PyList_New(0);
    if (!dns_result) {
        PyErr_NoMemory();
        PyErr_WriteUnraisable(Py_None);
        errorno = PyInt_FromLong((long)ARES_ENOMEM);
        dns_result = Py_None;
        Py_INCREF(Py_None);
        goto callback;
    }

    tmp = Py_BuildValue("s", hostent->h_name);
    PyList_Append(dns_result, tmp);
    Py_DECREF(tmp);
    errorno = Py_None;
    Py_INCREF(Py_None);

callback:
    result = PyObject_CallFunctionObjArgs(callback, dns_result, errorno, NULL);
    if (result == NULL) {
        PyErr_WriteUnraisable(callback);
    }
    Py_XDECREF(result);
    Py_DECREF(dns_result);
    Py_DECREF(errorno);
    if (hostent) {
        ares_free_hostent(hostent);
    }
    Py_DECREF(callback);
    PyGILState_Release(gstate);
}
开发者ID:IsCoolEntertainment,项目名称:debpkg_python-pycares,代码行数:56,代码来源:cares.c


示例7: nameinfo_cb

static void
nameinfo_cb(void *arg, int status, int timeouts, char *node, char *service)
{
    PyGILState_STATE gstate = PyGILState_Ensure();
    PyObject *callback, *errorno, *dns_node, *dns_service, *dns_result, *result;

    callback = (PyObject *)arg;
    ASSERT(callback);

    if (status != ARES_SUCCESS) {
        errorno = PyInt_FromLong((long)status);
        dns_result = Py_None;
        Py_INCREF(Py_None);
        goto callback;
    }

    dns_result = PyStructSequence_New(&AresNameinfoResultType);
    if (!dns_result) {
        PyErr_NoMemory();
        PyErr_WriteUnraisable(Py_None);
        errorno = PyInt_FromLong((long)ARES_ENOMEM);
        dns_result = Py_None;
        Py_INCREF(Py_None);
        goto callback;
    }

    dns_node = Py_BuildValue("s", node);
    if (service) {
        dns_service = Py_BuildValue("s", service);
    } else {
        dns_service = Py_None;
        Py_INCREF(Py_None);
    }

    PyStructSequence_SET_ITEM(dns_result, 0, dns_node);
    PyStructSequence_SET_ITEM(dns_result, 1, dns_service);
    errorno = Py_None;
    Py_INCREF(Py_None);

callback:
    result = PyObject_CallFunctionObjArgs(callback, dns_result, errorno, NULL);
    if (result == NULL) {
        PyErr_WriteUnraisable(callback);
    }
    Py_XDECREF(result);
    Py_DECREF(dns_result);
    Py_DECREF(errorno);

    Py_DECREF(callback);
    PyGILState_Release(gstate);
}
开发者ID:IsCoolEntertainment,项目名称:debpkg_python-pycares,代码行数:51,代码来源:cares.c


示例8: music_delivery

static int
music_delivery(sp_session * session, const sp_audioformat * format,
               const void *frames, int num_frames)
{
    /* TODO: This is called _all_ the time, make it faster? */

    // Note that we do not try to shoe horn this into session_callback as it is
    // quite different in that this needs to handle return values and much more
    // complicated arguments.

    debug_printf(">> music_delivery called: frames %d", num_frames);

    int consumed = num_frames;  // assume all consumed
    int size = frame_size(format);

    PyObject *callback, *client, *py_frames, *py_session, *result;
    PyGILState_STATE gstate = PyGILState_Ensure();

    /* TODO: check if session creations succeeds. */
    py_frames = PyBuffer_FromMemory((void *)frames, num_frames * size);
    py_session = Session_FromSpotify(session);

    /* TODO: check if callback get succeeds. */
    client = (PyObject *)sp_session_userdata(session);
    callback = PyObject_GetAttrString(client, "music_delivery");

    result = PyObject_CallFunction(callback, "NNiiiii", py_session, py_frames,
                                   size, num_frames, format->sample_type,
                                   format->sample_rate, format->channels);

    if (result == NULL)
        PyErr_WriteUnraisable(callback);
    else {
        if (PyInt_Check(result))
            consumed = (int)PyInt_AsLong(result);
        else if (PyLong_Check(result))
            consumed = (int)PyLong_AsLong(result);
        else {
            PyErr_SetString(PyExc_TypeError,
                            "music_delivery must return an integer");
            PyErr_WriteUnraisable(callback);
        }
        Py_DECREF(result);
    }
    Py_XDECREF(callback);
    PyGILState_Release(gstate);
    return consumed;
}
开发者ID:ZenithDK,项目名称:pyspotify,代码行数:48,代码来源:session.c


示例9: EXCEPTION_MATCH_GENERATOR

NUITKA_MAY_BE_UNUSED static bool EXCEPTION_MATCH_GENERATOR( PyObject *exception_value )
{
    CHECK_OBJECT( exception_value );

    // We need to check the class.
    if ( PyExceptionInstance_Check( exception_value ) )
    {
        exception_value = PyExceptionInstance_Class( exception_value );
    }

    // Lets be optimistic. If it matches, we would be wasting our time.
    if ( exception_value == PyExc_GeneratorExit || exception_value == PyExc_StopIteration )
    {
        return true;
    }

    if ( PyExceptionClass_Check( exception_value ) )
    {
        // Save the current exception, if any, we must preserve it.
        PyObject *save_exception_type, *save_exception_value;
        PyTracebackObject *save_exception_tb;
        FETCH_ERROR_OCCURRED( &save_exception_type, &save_exception_value, &save_exception_tb );

        int res = PyObject_IsSubclass( exception_value, PyExc_GeneratorExit );

        // This function must not fail, so print the error here */
        if (unlikely( res == -1 ))
        {
            PyErr_WriteUnraisable( exception_value );
        }

        if (res == 1) return true;

        res = PyObject_IsSubclass( exception_value, PyExc_StopIteration );

        // This function must not fail, so print the error here */
        if (unlikely( res == -1 ))
        {
            PyErr_WriteUnraisable( exception_value );
        }

        RESTORE_ERROR_OCCURRED( save_exception_type, save_exception_value, save_exception_tb );

        return res == 1;
    }

    return false;
}
开发者ID:justus922,项目名称:Nuitka,代码行数:48,代码来源:exceptions.hpp


示例10: flush_std_files

static int
flush_std_files(void)
{
    PyObject *fout = _PySys_GetObjectId(&PyId_stdout);
    PyObject *ferr = _PySys_GetObjectId(&PyId_stderr);
    PyObject *tmp;
    int status = 0;

    if (fout != NULL && fout != Py_None && !file_is_closed(fout)) {
        tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
        if (tmp == NULL) {
            PyErr_WriteUnraisable(fout);
            status = -1;
        }
        else
            Py_DECREF(tmp);
    }

    if (ferr != NULL && ferr != Py_None && !file_is_closed(ferr)) {
        tmp = _PyObject_CallMethodId(ferr, &PyId_flush, "");
        if (tmp == NULL) {
            PyErr_Clear();
            status = -1;
        }
        else
            Py_DECREF(tmp);
    }

    return status;
}
开发者ID:yoongkang,项目名称:cpython,代码行数:30,代码来源:pylifecycle.c


示例11: __Pyx_Generator_CloseIter

//   This helper function is used by gen_close and gen_throw to
//   close a subiterator being delegated to by yield-from.
static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;

    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Generator_Close(yf);
        if (!retval)
            return -1;
    } else {
        PyObject *meth;
        gen->is_running = 1;
        meth = PyObject_GetAttrString(yf, "close");
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
开发者ID:dhirschfeld,项目名称:cython,代码行数:30,代码来源:Generator.c


示例12: igraphmodule_filehandle_destroy

/**
 * \ingroup python_interface_filehandle
 * \brief Destroys the file handle object.
 */
void igraphmodule_filehandle_destroy(igraphmodule_filehandle_t* handle) {
    PyObject *exc_type = 0, *exc_value = 0, *exc_traceback = 0;

    if (handle->fp != 0) {
        fflush(handle->fp);
        if (handle->need_close && !handle->object) {
            fclose(handle->fp);
        }
    }

    handle->fp = 0;
    
    if (handle->object != 0) {
        /* PyFile_Close might mess up the stored exception, so let's
         * store the current exception state and restore it */
        PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
        if (handle->need_close) {
            if (PyFile_Close(handle->object)) {
                PyErr_WriteUnraisable(Py_None);
            }
        }
        Py_DECREF(handle->object);
        PyErr_Restore(exc_type, exc_value, exc_traceback);
        exc_type = exc_value = exc_traceback = 0;
        handle->object = 0;
    }

    handle->need_close = 0;
}
开发者ID:Sarmentor,项目名称:python-igraph,代码行数:33,代码来源:filehandle.c


示例13: notify_main_thread

static void
notify_main_thread(sp_session * session)
{
    PyGILState_STATE gstate;
    PyObject *res, *method;

#ifdef DEBUG
        fprintf(stderr, "[DEBUG]-session- >> notify_main_thread called\n");
#endif
    if (!session_constructed)
        return;
    gstate = PyGILState_Ensure();
    Session *psession =
        (Session *) PyObject_CallObject((PyObject *)&SessionType, NULL);
    psession->_session = session;
    PyObject *client = (PyObject *)sp_session_userdata(session);

    if (client != NULL) {
        method = PyObject_GetAttrString(client, "wake");
        res = PyObject_CallFunctionObjArgs(method, psession, NULL);
        if (!res)
            PyErr_WriteUnraisable(method);
        Py_XDECREF(res);
        Py_DECREF(method);
    }
    Py_DECREF(psession);
    PyGILState_Release(gstate);
}
开发者ID:JoeConyers,项目名称:SpotifyRemote,代码行数:28,代码来源:session.c


示例14: gen_close_iter

static int
gen_close_iter(PyObject *yf)
{
    PyObject *retval = NULL;
    _Py_IDENTIFIER(close);

    if (PyGen_CheckExact(yf)) {
        retval = gen_close((PyGenObject *)yf, NULL);
        if (retval == NULL)
            return -1;
    } else {
        PyObject *meth = _PyObject_GetAttrId(yf, &PyId_close);
        if (meth == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                PyErr_WriteUnraisable(yf);
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, "");
            Py_DECREF(meth);
            if (retval == NULL)
                return -1;
        }
    }
    Py_XDECREF(retval);
    return 0;
}
开发者ID:DinoV,项目名称:gilectomy,代码行数:26,代码来源:genobject.c


示例15: ares__sock_state_cb

static void
ares__sock_state_cb(void *data, ares_socket_t socket_fd, int readable, int writable)
{
    PyGILState_STATE gstate = PyGILState_Ensure();
    Channel *self;
    PyObject *result, *fd, *py_readable, *py_writable;

    self = (Channel *)data;
    ASSERT(self);
    /* Object could go out of scope in the callback, increase refcount to avoid it */
    Py_INCREF(self);

    fd = PyInt_FromLong((long)socket_fd);
    py_readable = PyBool_FromLong((long)readable);
    py_writable = PyBool_FromLong((long)writable);

    result = PyObject_CallFunctionObjArgs(self->sock_state_cb, fd, py_readable, py_writable, NULL);
    if (result == NULL) {
        PyErr_WriteUnraisable(self->sock_state_cb);
    }
    Py_XDECREF(result);
    Py_DECREF(fd);
    Py_DECREF(py_readable);
    Py_DECREF(py_writable);

    Py_DECREF(self);
    PyGILState_Release(gstate);
}
开发者ID:IsCoolEntertainment,项目名称:debpkg_python-pycares,代码行数:28,代码来源:cares.c


示例16: psyco_flog

DEFINEFN
void psyco_flog(char* msg, ...)
{
  va_list vargs;
  PyObject* s;
  PyObject* r;
  PyObject *etype, *evalue, *etb;
  extra_assert(psyco_logger != NULL);

  PyErr_Fetch(&etype, &evalue, &etb);
  
#ifdef HAVE_STDARG_PROTOTYPES
  va_start(vargs, msg);
#else
  va_start(vargs);
#endif
  s = PyString_FromFormatV(msg, vargs);
  va_end(vargs);

  if (s == NULL)
    OUT_OF_MEMORY();
  r = PyObject_CallFunction(psyco_logger, "O", s);
  if (r == NULL)
    PyErr_WriteUnraisable(psyco_logger);
  else
    Py_DECREF(r);
  Py_DECREF(s);

  PyErr_Restore(etype, evalue, etb);
}
开发者ID:Galland,项目名称:nodebox-opengl,代码行数:30,代码来源:psyco.c


示例17: publickey_sign_callback

static int publickey_sign_callback(LIBSSH2_SESSION *session,
                                   unsigned char **sig, size_t *sig_len,
                                   const unsigned char *data, size_t data_len,
                                   void **abstract)
{
	PyObject *callback = (PyObject *) *abstract;
	PyObject *rv;
	PyGILState_STATE gstate = PyGILState_Ensure();
	char *s;
	int ret = -1;

#if PY_MAJOR_VERSION < 3
	rv = PyObject_CallFunction(callback, "s#", data, data_len);
#else
	rv = PyObject_CallFunction(callback, "y#", data, data_len);
#endif

	if (rv == NULL)
		goto failure;

	ret = PyBytes_AsStringAndSize(rv, &s, (Py_ssize_t *) sig_len);
	Py_DECREF(rv);

	if (ret == 0) {
		*sig = (unsigned char*) strndup(s, *sig_len);
		goto exit;
	}

failure:
	PyErr_WriteUnraisable(callback);
exit:
	PyGILState_Release(gstate);
	return ret;
}
开发者ID:vianney,项目名称:ssh4py,代码行数:34,代码来源:session.c


示例18: log_message

static void
log_message(sp_session * session, const char *data)
{
    PyGILState_STATE gstate;
    PyObject *res, *method, *msg;

#ifdef DEBUG
        fprintf(stderr, "[DEBUG]-session- >> log message: %s\n", data);
#endif
    gstate = PyGILState_Ensure();
    Session *psession =
        (Session *) PyObject_CallObject((PyObject *)&SessionType, NULL);
    psession->_session = session;
    PyObject *client = (PyObject *)sp_session_userdata(session);

    msg = PyUnicode_FromString(data);
    method = PyObject_GetAttrString(client, "log_message");
    res = PyObject_CallFunctionObjArgs(method, psession, msg, NULL);
    if (!res)
        PyErr_WriteUnraisable(method);
    Py_DECREF(psession);
    Py_XDECREF(res);
    Py_DECREF(msg);
    Py_DECREF(method);
    PyGILState_Release(gstate);
}
开发者ID:JoeConyers,项目名称:SpotifyRemote,代码行数:26,代码来源:session.c


示例19: gen_del

static void
gen_del(PyObject *self)
{
    PyObject *res;
    PyObject *error_type, *error_value, *error_traceback;
    PyGenObject *gen = (PyGenObject *)self;

    if (gen->gi_frame == NULL || gen->gi_frame->f_stacktop == NULL)
        /* Generator isn't paused, so no need to close */
        return;

    /* Temporarily resurrect the object. */
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;

    /* Save the current exception, if any. */
    PyErr_Fetch(&error_type, &error_value, &error_traceback);

    res = gen_close(gen, NULL);

    if (res == NULL)
        PyErr_WriteUnraisable(self);
    else
        Py_DECREF(res);

    /* Restore the saved exception. */
    PyErr_Restore(error_type, error_value, error_traceback);

    /* Undo the temporary resurrection; can't use DECREF here, it would
     * cause a recursive call.
     */
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0)
        return; /* this is the normal path out */

    /* close() resurrected it!  Make it look like the original Py_DECREF
     * never happened.
     */
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        self->ob_refcnt = refcnt;
    }
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);

    /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
     * we need to undo that. */
    _Py_DEC_REFTOTAL;
    /* If Py_TRACE_REFS, _Py_NewReference re-added self to the object
     * chain, so no more to do there.
     * If COUNT_ALLOCS, the original decref bumped tp_frees, and
     * _Py_NewReference bumped tp_allocs:  both of those need to be
     * undone.
     */
#ifdef COUNT_ALLOCS
    --self->ob_type->tp_frees;
    --self->ob_type->tp_allocs;
#endif
}
开发者ID:newerthcom,项目名称:savagerebirth,代码行数:60,代码来源:genobject.c


示例20: Nuitka_Generator_tp_del

static void Nuitka_Generator_tp_del( struct Nuitka_GeneratorObject *generator )
{
    if ( generator->m_status != status_Running )
    {
        return;
    }

    PyObject *error_type, *error_value;
    PyTracebackObject *error_traceback;

    FETCH_ERROR_OCCURRED( &error_type, &error_value, &error_traceback );

    PyObject *close_result = Nuitka_Generator_close( generator, NULL );

    if (unlikely( close_result == NULL ))
    {
        PyErr_WriteUnraisable( (PyObject *)generator );
    }
    else
    {
        Py_DECREF( close_result );
    }

    /* Restore the saved exception if any. */
    RESTORE_ERROR_OCCURRED( error_type, error_value, error_traceback );
}
开发者ID:fluxer,项目名称:spm,代码行数:26,代码来源:CompiledGeneratorType.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyEval_AcquireLock函数代码示例发布时间:2022-05-30
下一篇:
C++ PyErr_SetString函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap