本文整理汇总了C++中Py_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ Py_TYPE函数的具体用法?C++ Py_TYPE怎么用?C++ Py_TYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Py_TYPE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RAISE_EXCEPTION_WITH_VALUE
NUITKA_NO_RETURN NUITKA_MAY_BE_UNUSED static void RAISE_EXCEPTION_WITH_VALUE( PyObject *exception_type, PyObject *value, PyObject *exception_tb )
{
assertObject( exception_type );
PyTracebackObject *traceback = (PyTracebackObject *)exception_tb;
// Non-empty tuple exceptions are the first element.
while (unlikely( PyTuple_Check( exception_type ) && PyTuple_Size( exception_type ) > 0 ))
{
exception_type = PyTuple_GET_ITEM( exception_type, 0 );
}
if ( PyExceptionClass_Check( exception_type ) )
{
Py_INCREF( exception_type );
Py_XINCREF( value );
Py_XINCREF( traceback );
NORMALIZE_EXCEPTION( &exception_type, &value, &traceback );
#if PYTHON_VERSION >= 270
if (unlikely( !PyExceptionInstance_Check( value ) ))
{
PyErr_Format(
PyExc_TypeError,
"calling %s() should have returned an instance of BaseException, not '%s'",
((PyTypeObject *)exception_type)->tp_name,
Py_TYPE( value )->tp_name
);
Py_DECREF( exception_type );
Py_XDECREF( value );
Py_XDECREF( traceback );
throw PythonException();
}
#endif
throw PythonException(
exception_type,
value,
traceback
);
}
else if ( PyExceptionInstance_Check( exception_type ) )
{
if (unlikely( value != NULL && value != Py_None ))
{
PyErr_Format(
PyExc_TypeError,
"instance exception may not have a separate value"
);
throw PythonException();
}
// The type is rather a value, so we are overriding it here.
value = exception_type;
exception_type = PyExceptionInstance_Class( exception_type );
throw PythonException(
INCREASE_REFCOUNT( exception_type ),
INCREASE_REFCOUNT( value ),
INCREASE_REFCOUNT_X( traceback )
);
}
else
{
PyErr_Format( PyExc_TypeError, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE, Py_TYPE( exception_type )->tp_name );
throw PythonException();
}
}
开发者ID:ballacky13,项目名称:Nuitka,代码行数:71,代码来源:raising.hpp
示例2: pyPageInfo_dealloc
static void pyPageInfo_dealloc(pyPageInfo* self) {
if (self->fPyOwned)
delete self->fThis;
Py_TYPE(self)->tp_free((PyObject*)self);
}
开发者ID:boq,项目名称:libhsplasma,代码行数:5,代码来源:pyPageInfo.cpp
示例3: srd_inst_option_set
/**
* Set one or more options in a decoder instance.
*
* Handled options are removed from the hash.
*
* @param di Decoder instance.
* @param options A GHashTable of options to set.
*
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_inst_option_set(struct srd_decoder_inst *di,
GHashTable *options)
{
PyObject *py_dec_options, *py_dec_optkeys, *py_di_options, *py_optval;
PyObject *py_optlist, *py_classval;
Py_UNICODE *py_ustr;
unsigned long long int val_ull;
int num_optkeys, ret, size, i;
char *key, *value;
if (!PyObject_HasAttrString(di->decoder->py_dec, "options")) {
/* Decoder has no options. */
if (g_hash_table_size(options) == 0) {
/* No options provided. */
return SRD_OK;
} else {
srd_err("Protocol decoder has no options.");
return SRD_ERR_ARG;
}
return SRD_OK;
}
ret = SRD_ERR_PYTHON;
key = NULL;
py_dec_options = py_dec_optkeys = py_di_options = py_optval = NULL;
py_optlist = py_classval = NULL;
py_dec_options = PyObject_GetAttrString(di->decoder->py_dec, "options");
/* All of these are synthesized objects, so they're good. */
py_dec_optkeys = PyDict_Keys(py_dec_options);
num_optkeys = PyList_Size(py_dec_optkeys);
if (!(py_di_options = PyObject_GetAttrString(di->py_inst, "options")))
goto err_out;
for (i = 0; i < num_optkeys; i++) {
/* Get the default class value for this option. */
py_str_as_str(PyList_GetItem(py_dec_optkeys, i), &key);
if (!(py_optlist = PyDict_GetItemString(py_dec_options, key)))
goto err_out;
if (!(py_classval = PyList_GetItem(py_optlist, 1)))
goto err_out;
if (!PyUnicode_Check(py_classval) && !PyLong_Check(py_classval)) {
srd_err("Options of type %s are not yet supported.",
Py_TYPE(py_classval)->tp_name);
goto err_out;
}
if ((value = g_hash_table_lookup(options, key))) {
/* An override for this option was provided. */
if (PyUnicode_Check(py_classval)) {
if (!(py_optval = PyUnicode_FromString(value))) {
/* Some UTF-8 encoding error. */
PyErr_Clear();
goto err_out;
}
} else if (PyLong_Check(py_classval)) {
if (!(py_optval = PyLong_FromString(value, NULL, 0))) {
/* ValueError Exception */
PyErr_Clear();
srd_err("Option %s has invalid value "
"%s: expected integer.",
key, value);
goto err_out;
}
}
g_hash_table_remove(options, key);
} else {
/* Use the class default for this option. */
if (PyUnicode_Check(py_classval)) {
/* Make a brand new copy of the string. */
py_ustr = PyUnicode_AS_UNICODE(py_classval);
size = PyUnicode_GET_SIZE(py_classval);
py_optval = PyUnicode_FromUnicode(py_ustr, size);
} else if (PyLong_Check(py_classval)) {
/* Make a brand new copy of the integer. */
val_ull = PyLong_AsUnsignedLongLong(py_classval);
if (val_ull == (unsigned long long)-1) {
/* OverFlowError exception */
PyErr_Clear();
srd_err("Invalid integer value for %s: "
"expected integer.", key);
goto err_out;
}
if (!(py_optval = PyLong_FromUnsignedLongLong(val_ull)))
goto err_out;
}
}
/*
* If we got here, py_optval holds a known good new reference
* to the instance option to set.
//.........这里部分代码省略.........
开发者ID:haavares,项目名称:sigrok,代码行数:101,代码来源:controller.c
示例4: Nuitka_Method_Check
static inline bool Nuitka_Method_Check( PyObject *object )
{
return Py_TYPE( object ) == &Nuitka_Method_Type;
}
开发者ID:601040605,项目名称:Nuitka,代码行数:4,代码来源:compiled_method.hpp
示例5: pypff_item_free
/* Frees an item object
*/
void pypff_item_free(
pypff_item_t *pypff_item )
{
libcerror_error_t *error = NULL;
struct _typeobject *ob_type = NULL;
static char *function = "pypff_item_free";
if( pypff_item == NULL )
{
PyErr_Format(
PyExc_TypeError,
"%s: invalid item.",
function );
return;
}
if( pypff_item->item == NULL )
{
PyErr_Format(
PyExc_TypeError,
"%s: invalid item - missing libpff item.",
function );
return;
}
ob_type = Py_TYPE(
pypff_item );
if( ob_type == NULL )
{
PyErr_Format(
PyExc_ValueError,
"%s: missing ob_type.",
function );
return;
}
if( ob_type->tp_free == NULL )
{
PyErr_Format(
PyExc_ValueError,
"%s: invalid ob_type - missing tp_free.",
function );
return;
}
if( libpff_item_free(
&( pypff_item->item ),
&error ) != 1 )
{
pypff_error_raise(
error,
PyExc_IOError,
"%s: unable to free libpff item.",
function );
libcerror_error_free(
&error );
}
if( pypff_item->file_object != NULL )
{
Py_DecRef(
(PyObject *) pypff_item->file_object );
}
ob_type->tp_free(
(PyObject*) pypff_item );
}
开发者ID:McDeCoderDude,项目名称:libpff,代码行数:69,代码来源:pypff_item.c
示例6: pybde_key_protector_free
/* Frees a key protector object
*/
void pybde_key_protector_free(
pybde_key_protector_t *pybde_key_protector )
{
libcerror_error_t *error = NULL;
struct _typeobject *ob_type = NULL;
static char *function = "pybde_key_protector_free";
if( pybde_key_protector == NULL )
{
PyErr_Format(
PyExc_TypeError,
"%s: invalid key protector.",
function );
return;
}
if( pybde_key_protector->key_protector == NULL )
{
PyErr_Format(
PyExc_TypeError,
"%s: invalid key protector - missing libbde key protector.",
function );
return;
}
ob_type = Py_TYPE(
pybde_key_protector );
if( ob_type == NULL )
{
PyErr_Format(
PyExc_ValueError,
"%s: missing ob_type.",
function );
return;
}
if( ob_type->tp_free == NULL )
{
PyErr_Format(
PyExc_ValueError,
"%s: invalid ob_type - missing tp_free.",
function );
return;
}
if( libbde_key_protector_free(
&( pybde_key_protector->key_protector ),
&error ) != 1 )
{
pybde_error_raise(
error,
PyExc_IOError,
"%s: unable to free libbde key protector.",
function );
libcerror_error_free(
&error );
}
if( pybde_key_protector->volume_object != NULL )
{
Py_DecRef(
(PyObject *) pybde_key_protector->volume_object );
}
ob_type->tp_free(
(PyObject*) pybde_key_protector );
}
开发者ID:elafonizi,项目名称:libbde,代码行数:69,代码来源:pybde_key_protector.c
示例7: inittest_array_from_pyobj_ext
PyObject *PyInit_test_array_from_pyobj_ext(void) {
#else
#define RETVAL
PyMODINIT_FUNC inittest_array_from_pyobj_ext(void) {
#endif
PyObject *m,*d, *s;
#if PY_VERSION_HEX >= 0x03000000
m = wrap_module = PyModule_Create(&moduledef);
#else
m = wrap_module = Py_InitModule("test_array_from_pyobj_ext", f2py_module_methods);
#endif
Py_TYPE(&PyFortran_Type) = &PyType_Type;
import_array();
if (PyErr_Occurred())
Py_FatalError("can't initialize module wrap (failed to import numpy)");
d = PyModule_GetDict(m);
s = PyString_FromString("This module 'wrap' is auto-generated with f2py (version:2_1330).\nFunctions:\n"
" arr = call(type_num,dims,intent,obj)\n"
".");
PyDict_SetItemString(d, "__doc__", s);
wrap_error = PyErr_NewException ("wrap.error", NULL, NULL);
Py_DECREF(s);
PyDict_SetItemString(d, "F2PY_INTENT_IN", PyInt_FromLong(F2PY_INTENT_IN));
PyDict_SetItemString(d, "F2PY_INTENT_INOUT", PyInt_FromLong(F2PY_INTENT_INOUT));
PyDict_SetItemString(d, "F2PY_INTENT_OUT", PyInt_FromLong(F2PY_INTENT_OUT));
PyDict_SetItemString(d, "F2PY_INTENT_HIDE", PyInt_FromLong(F2PY_INTENT_HIDE));
PyDict_SetItemString(d, "F2PY_INTENT_CACHE", PyInt_FromLong(F2PY_INTENT_CACHE));
PyDict_SetItemString(d, "F2PY_INTENT_COPY", PyInt_FromLong(F2PY_INTENT_COPY));
PyDict_SetItemString(d, "F2PY_INTENT_C", PyInt_FromLong(F2PY_INTENT_C));
PyDict_SetItemString(d, "F2PY_OPTIONAL", PyInt_FromLong(F2PY_OPTIONAL));
PyDict_SetItemString(d, "F2PY_INTENT_INPLACE", PyInt_FromLong(F2PY_INTENT_INPLACE));
PyDict_SetItemString(d, "PyArray_BOOL", PyInt_FromLong(PyArray_BOOL));
PyDict_SetItemString(d, "PyArray_BYTE", PyInt_FromLong(PyArray_BYTE));
PyDict_SetItemString(d, "PyArray_UBYTE", PyInt_FromLong(PyArray_UBYTE));
PyDict_SetItemString(d, "PyArray_SHORT", PyInt_FromLong(PyArray_SHORT));
PyDict_SetItemString(d, "PyArray_USHORT", PyInt_FromLong(PyArray_USHORT));
PyDict_SetItemString(d, "PyArray_INT", PyInt_FromLong(PyArray_INT));
PyDict_SetItemString(d, "PyArray_UINT", PyInt_FromLong(PyArray_UINT));
PyDict_SetItemString(d, "PyArray_INTP", PyInt_FromLong(PyArray_INTP));
PyDict_SetItemString(d, "PyArray_UINTP", PyInt_FromLong(PyArray_UINTP));
PyDict_SetItemString(d, "PyArray_LONG", PyInt_FromLong(PyArray_LONG));
PyDict_SetItemString(d, "PyArray_ULONG", PyInt_FromLong(PyArray_ULONG));
PyDict_SetItemString(d, "PyArray_LONGLONG", PyInt_FromLong(PyArray_LONGLONG));
PyDict_SetItemString(d, "PyArray_ULONGLONG", PyInt_FromLong(PyArray_ULONGLONG));
PyDict_SetItemString(d, "PyArray_FLOAT", PyInt_FromLong(PyArray_FLOAT));
PyDict_SetItemString(d, "PyArray_DOUBLE", PyInt_FromLong(PyArray_DOUBLE));
PyDict_SetItemString(d, "PyArray_LONGDOUBLE", PyInt_FromLong(PyArray_LONGDOUBLE));
PyDict_SetItemString(d, "PyArray_CFLOAT", PyInt_FromLong(PyArray_CFLOAT));
PyDict_SetItemString(d, "PyArray_CDOUBLE", PyInt_FromLong(PyArray_CDOUBLE));
PyDict_SetItemString(d, "PyArray_CLONGDOUBLE", PyInt_FromLong(PyArray_CLONGDOUBLE));
PyDict_SetItemString(d, "PyArray_OBJECT", PyInt_FromLong(PyArray_OBJECT));
PyDict_SetItemString(d, "PyArray_STRING", PyInt_FromLong(PyArray_STRING));
PyDict_SetItemString(d, "PyArray_UNICODE", PyInt_FromLong(PyArray_UNICODE));
PyDict_SetItemString(d, "PyArray_VOID", PyInt_FromLong(PyArray_VOID));
PyDict_SetItemString(d, "PyArray_NTYPES", PyInt_FromLong(PyArray_NTYPES));
PyDict_SetItemString(d, "PyArray_NOTYPE", PyInt_FromLong(PyArray_NOTYPE));
PyDict_SetItemString(d, "PyArray_UDERDEF", PyInt_FromLong(PyArray_USERDEF));
PyDict_SetItemString(d, "CONTIGUOUS", PyInt_FromLong(NPY_CONTIGUOUS));
PyDict_SetItemString(d, "FORTRAN", PyInt_FromLong(NPY_FORTRAN));
PyDict_SetItemString(d, "OWNDATA", PyInt_FromLong(NPY_OWNDATA));
PyDict_SetItemString(d, "FORCECAST", PyInt_FromLong(NPY_FORCECAST));
PyDict_SetItemString(d, "ENSURECOPY", PyInt_FromLong(NPY_ENSURECOPY));
PyDict_SetItemString(d, "ENSUREARRAY", PyInt_FromLong(NPY_ENSUREARRAY));
PyDict_SetItemString(d, "ALIGNED", PyInt_FromLong(NPY_ALIGNED));
PyDict_SetItemString(d, "WRITEABLE", PyInt_FromLong(NPY_WRITEABLE));
PyDict_SetItemString(d, "UPDATEIFCOPY", PyInt_FromLong(NPY_UPDATEIFCOPY));
PyDict_SetItemString(d, "BEHAVED", PyInt_FromLong(NPY_BEHAVED));
PyDict_SetItemString(d, "BEHAVED_NS", PyInt_FromLong(NPY_BEHAVED_NS));
PyDict_SetItemString(d, "CARRAY", PyInt_FromLong(NPY_CARRAY));
PyDict_SetItemString(d, "FARRAY", PyInt_FromLong(NPY_FARRAY));
PyDict_SetItemString(d, "CARRAY_RO", PyInt_FromLong(NPY_CARRAY_RO));
PyDict_SetItemString(d, "FARRAY_RO", PyInt_FromLong(NPY_FARRAY_RO));
PyDict_SetItemString(d, "DEFAULT", PyInt_FromLong(NPY_DEFAULT));
PyDict_SetItemString(d, "UPDATE_ALL", PyInt_FromLong(NPY_UPDATE_ALL));
if (PyErr_Occurred())
Py_FatalError("can't initialize module wrap");
#ifdef F2PY_REPORT_ATEXIT
on_exit(f2py_report_on_exit,(void*)"array_from_pyobj.wrap.call");
#endif
return RETVAL;
}
开发者ID:8cH9azbsFifZ,项目名称:wspr,代码行数:86,代码来源:wrapmodule.c
示例8: _BaseMathObject_RaiseNotFrozenExc
void _BaseMathObject_RaiseNotFrozenExc(const BaseMathObject *self)
{
PyErr_Format(PyExc_TypeError,
"%s is not frozen (mutable), call freeze first",
Py_TYPE(self)->tp_name);
}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:6,代码来源:mathutils.c
示例9: pyBitVector_dealloc
static void pyBitVector_dealloc(pyBitVector* self) {
if (self->fPyOwned)
delete self->fThis;
Py_TYPE(self)->tp_free((PyObject*)self);
}
开发者ID:GPNMilano,项目名称:libhsplasma,代码行数:5,代码来源:pyBitVector.cpp
示例10: PyArray_DTypeFromObjectHelper
//.........这里部分代码省略.........
}
Py_DECREF(ip);
}
/* The array struct interface */
ip = PyArray_LookupSpecial_OnInstance(obj, "__array_struct__");
if (ip != NULL) {
PyArrayInterface *inter;
char buf[40];
if (NpyCapsule_Check(ip)) {
inter = (PyArrayInterface *)NpyCapsule_AsVoidPtr(ip);
if (inter->two == 2) {
PyOS_snprintf(buf, sizeof(buf),
"|%c%d", inter->typekind, inter->itemsize);
dtype = _array_typedescr_fromstr(buf);
Py_DECREF(ip);
if (dtype == NULL) {
goto fail;
}
goto promote_types;
}
}
Py_DECREF(ip);
}
/* The old buffer interface */
#if !defined(NPY_PY3K)
if (PyBuffer_Check(obj)) {
dtype = PyArray_DescrNewFromType(NPY_VOID);
if (dtype == NULL) {
goto fail;
}
dtype->elsize = Py_TYPE(obj)->tp_as_sequence->sq_length(obj);
PyErr_Clear();
goto promote_types;
}
#endif
/* The __array__ attribute */
ip = PyArray_LookupSpecial_OnInstance(obj, "__array__");
if (ip != NULL) {
Py_DECREF(ip);
ip = PyObject_CallMethod(obj, "__array__", NULL);
if(ip && PyArray_Check(ip)) {
dtype = PyArray_DESCR((PyArrayObject *)ip);
Py_INCREF(dtype);
Py_DECREF(ip);
goto promote_types;
}
Py_XDECREF(ip);
if (PyErr_Occurred()) {
goto fail;
}
}
/*
* If we reached the maximum recursion depth without hitting one
* of the above cases, and obj isn't a sequence-like object, the output
* dtype should be either OBJECT or a user-defined type.
*
* Note that some libraries define sequence-like classes but want them to
* be treated as objects, and they expect numpy to treat it as an object if
* __len__ is not defined.
*/
if (maxdims == 0 || !PySequence_Check(obj) || PySequence_Size(obj) < 0) {
开发者ID:mingwandroid,项目名称:numpy,代码行数:67,代码来源:common.c
示例11: _BaseMathObject_RaiseFrozenExc
void _BaseMathObject_RaiseFrozenExc(const BaseMathObject *self)
{
PyErr_Format(PyExc_TypeError,
"%s is frozen (immutable)",
Py_TYPE(self)->tp_name);
}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:6,代码来源:mathutils.c
示例12: event_ob__init
//.........这里部分代码省略.........
"exclude_user",
"exclude_kernel",
"exclude_hv",
"exclude_idle",
"mmap",
"comm",
"freq",
"inherit_stat",
"enable_on_exec",
"task",
"watermark",
"precise_ip",
"mmap_data",
"sample_id_all",
"wakeup_events",
"bp_type",
"bp_addr",
"bp_len",
NULL
};
uint64_t sample_period = 0;
uint32_t disabled = 0,
inherit = 0,
pinned = 0,
exclusive = 0,
exclude_user = 0,
exclude_kernel = 0,
exclude_hv = 0,
exclude_idle = 0,
mmap = 0,
comm = 0,
freq = 1,
inherit_stat = 0,
enable_on_exec = 0,
task = 0,
watermark = 0,
precise_ip = 0,
mmap_data = 0,
sample_id_all = 1;
int idx = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"|iKiKKiiiiiiiiiiiiiiiiiiiiiKK", kwlist,
&attr.type, &attr.config, &attr.sample_freq,
&sample_period, &attr.sample_type,
&attr.read_format, &disabled, &inherit,
&pinned, &exclusive, &exclude_user,
&exclude_kernel, &exclude_hv, &exclude_idle,
&mmap, &comm, &freq, &inherit_stat,
&enable_on_exec, &task, &watermark,
&precise_ip, &mmap_data, &sample_id_all,
&attr.wakeup_events, &attr.bp_type,
&attr.bp_addr, &attr.bp_len, &idx))
return -1;
/* union... */
if (sample_period != 0) {
if (attr.sample_freq != 0) {
PyErr_SetString(PyExc_AttributeError, "Event frequency or period required, not both");
return -1;
}
if (freq != 0) {
PyErr_SetString(PyExc_AttributeError, "sample_period set requires freq equal to zero");
return -1;
}
attr.sample_period = sample_period;
}
/* Bitfields */
attr.disabled = disabled;
attr.inherit = inherit;
attr.pinned = pinned;
attr.exclusive = exclusive;
attr.exclude_user = exclude_user;
attr.exclude_kernel = exclude_kernel;
attr.exclude_hv = exclude_hv;
attr.exclude_idle = exclude_idle;
attr.mmap = mmap;
attr.comm = comm;
attr.freq = freq;
attr.inherit_stat = inherit_stat;
attr.enable_on_exec = enable_on_exec;
attr.task = task;
attr.watermark = watermark;
attr.precise_ip = precise_ip;
attr.mmap_data = mmap_data;
attr.sample_id_all = sample_id_all;
self->attr = attr;
self->status = EVENT_STATUS_CLOSED;
self->monitor = EVENT_MONITOR_TRACEBACK;
self->fd = -1;
return 0;
}
void event_ob__dealloc(PyPerfEvent *self)
{
Py_TYPE(self)->tp_free((PyObject*)self);
}
开发者ID:foundjem,项目名称:python-profile-ust,代码行数:101,代码来源:sampling.c
示例13: slice_reduce
static PyObject *
slice_reduce(PySliceObject* self, PyObject *Py_UNUSED(ignored))
{
return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step);
}
开发者ID:adrian17,项目名称:cpython,代码行数:5,代码来源:sliceobject.c
示例14: RAISE_EXCEPTION_WITH_TYPE
NUITKA_NO_RETURN NUITKA_MAY_BE_UNUSED static void RAISE_EXCEPTION_WITH_TYPE( PyObject *exception_type, PyObject *exception_tb )
{
PyTracebackObject *traceback = (PyTracebackObject *)exception_tb;
assertObject( traceback );
assert( PyTraceBack_Check( traceback ) );
assertObject( exception_type );
if ( PyExceptionClass_Check( exception_type ) )
{
PyObject *value = NULL;
Py_INCREF( exception_type );
Py_XINCREF( traceback );
NORMALIZE_EXCEPTION( &exception_type, &value, &traceback );
#if PYTHON_VERSION >= 270
if (unlikely( !PyExceptionInstance_Check( value ) ))
{
Py_DECREF( exception_type );
Py_DECREF( value );
Py_XDECREF( traceback );
PyErr_Format(
PyExc_TypeError,
"calling %s() should have returned an instance of BaseException, not '%s'",
((PyTypeObject *)exception_type)->tp_name,
Py_TYPE( value )->tp_name
);
throw PythonException();
}
#endif
#if PYTHON_VERSION >= 300
CHAIN_EXCEPTION( exception_type, value );
#endif
throw PythonException(
exception_type,
value,
traceback
);
}
else if ( PyExceptionInstance_Check( exception_type ) )
{
PyObject *value = exception_type;
exception_type = PyExceptionInstance_Class( exception_type );
#if PYTHON_VERSION >= 300
CHAIN_EXCEPTION( exception_type, value );
PyTracebackObject *prev = (PyTracebackObject *)PyException_GetTraceback( value );
if ( prev != NULL )
{
assert( traceback->tb_next == NULL );
traceback->tb_next = prev;
}
PyException_SetTraceback( value, (PyObject *)traceback );
#endif
throw PythonException(
INCREASE_REFCOUNT( exception_type ),
INCREASE_REFCOUNT( value ),
INCREASE_REFCOUNT( traceback )
);
}
else
{
PyErr_Format( PyExc_TypeError, WRONG_EXCEPTION_TYPE_ERROR_MESSAGE, Py_TYPE( exception_type )->tp_name );
PythonException to_throw;
to_throw.setTraceback( INCREASE_REFCOUNT( traceback ) );
throw to_throw;
}
}
开发者ID:ballacky13,项目名称:Nuitka,代码行数:77,代码来源:raising.hpp
示例15: peer_dealloc
static void peer_dealloc(PyObject *peer) noexcept
{
reinterpret_cast<PeerObject *> (peer)->~PeerObject();
Py_TYPE(peer)->tp_free(peer);
}
开发者ID:tsavola,项目名称:tap,代码行数:5,代码来源:peer.cpp
示例16: DyND_PyWrapper_CheckExact
int DyND_PyWrapper_CheckExact(PyObject *obj)
{
return Py_TYPE(obj) == DyND_PyWrapper_Type<T>();
}
开发者ID:mdboom,项目名称:dynd-python,代码行数:4,代码来源:wrapper.hpp
示例17: Event_dealloc
static void
Event_dealloc(pycbc_Event *self)
{
Event_gc_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
开发者ID:sandipnd,项目名称:couchbase-python-client,代码行数:6,代码来源:iops.c
示例18: verifying_dealloc
static void
verifying_dealloc(verify *self)
{
verifying_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
开发者ID:Bludge0n,项目名称:Python-for-Android,代码行数:6,代码来源:_zope_interface_coptimizations.c
示例19: range_reduce
/* Pickling support */
static PyObject *
range_reduce(rangeobject *r, PyObject *args)
{
return Py_BuildValue("(O(OOO))", Py_TYPE(r),
r->start, r->stop, r->step);
}
开发者ID:FFMG,项目名称:myoddweb.piger,代码行数:7,代码来源:rangeobject.c
示例20: lookup_dealloc
static void
lookup_dealloc(lookup *self)
{
lookup_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
开发者ID:Bludge0n,项目名称:Python-for-Android,代码行数:6,代码来源:_zope_interface_coptimizations.c
注:本文中的Py_TYPE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论