本文整理汇总了C++中PyErr_NewException函数的典型用法代码示例。如果您正苦于以下问题:C++ PyErr_NewException函数的具体用法?C++ PyErr_NewException怎么用?C++ PyErr_NewException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyErr_NewException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PyInit__gdbm
PyMODINIT_FUNC
PyInit__gdbm(void) {
PyObject *m, *d, *s;
if (PyType_Ready(&Dbmtype) < 0)
return NULL;
m = PyModule_Create(&_gdbmmodule);
if (m == NULL)
return NULL;
d = PyModule_GetDict(m);
DbmError = PyErr_NewException("_gdbm.error", PyExc_IOError, NULL);
if (DbmError != NULL) {
PyDict_SetItemString(d, "error", DbmError);
s = PyUnicode_FromString(dbmmodule_open_flags);
PyDict_SetItemString(d, "open_flags", s);
Py_DECREF(s);
}
return m;
}
开发者ID:ARK4579,项目名称:cpython,代码行数:19,代码来源:_gdbmmodule.c
示例2: initumemcache
PyMODINIT_FUNC
initumemcache(void)
{
PyObject* m;
m = Py_InitModule3("umemcache", methods, "");
if (m == NULL)
return;
ClientType.tp_new = PyType_GenericNew;
if (PyType_Ready(&ClientType) < 0)
return;
Py_INCREF(&ClientType);
PyModule_AddObject(m, "Client", (PyObject *)&ClientType);
umemcache_MemcachedError = PyErr_NewException("umemcache.MemcachedError",
PyExc_RuntimeError, NULL);
PyModule_AddObject(m, "MemcachedError", (PyObject *)umemcache_MemcachedError);
}
开发者ID:philipsoutham,项目名称:ultramemcache,代码行数:19,代码来源:umemcache.cpp
示例3: initVmMngr
PyMODINIT_FUNC
initVmMngr(void)
{
PyObject *m;
if (PyType_Ready(&VmMngrType) < 0)
return;
m = Py_InitModule("VmMngr", VmMngr_Methods);
if (m == NULL)
return;
Vm_Mngr_Error = PyErr_NewException("VmMngr.error", NULL, NULL);
Py_INCREF(Vm_Mngr_Error);
PyModule_AddObject(m, "error", Vm_Mngr_Error);
Py_INCREF(&VmMngrType);
PyModule_AddObject(m, "Vm", (PyObject *)&VmMngrType);
}
开发者ID:Zke1ev3n,项目名称:miasm,代码行数:19,代码来源:vm_mngr_py.c
示例4: PyModule_Create
PyObject *PyInit__minpack(void)
{
PyObject *m, *d, *s;
m = PyModule_Create(&moduledef);
import_array();
d = PyModule_GetDict(m);
s = PyUnicode_FromString(" 1.10 ");
PyDict_SetItemString(d, "__version__", s);
Py_DECREF(s);
minpack_error = PyErr_NewException ("minpack.error", NULL, NULL);
PyDict_SetItemString(d, "error", minpack_error);
if (PyErr_Occurred())
Py_FatalError("can't initialize module minpack");
return m;
}
开发者ID:1641731459,项目名称:scipy,代码行数:19,代码来源:_minpackmodule.c
示例5: initpyhook
PyMODINIT_FUNC
initpyhook(void) {
PyObject *m;
pyhook_StreetAddressLookupType.tp_members = StreetAddressLookup_members;
if (PyType_Ready(&pyhook_StreetAddressLookupType) < 0)
return;
m = Py_InitModule("pyhook", PyhookMethods);
if (m == NULL)
return;
PyhookError = PyErr_NewException("pyhook.error", NULL, NULL);
Py_INCREF(PyhookError);
PyModule_AddObject(m, "error", PyhookError);
Py_INCREF(&pyhook_StreetAddressLookupType);
PyModule_AddObject(m, "StreetAddressLookup", StreetAddressLookup_new(&pyhook_StreetAddressLookupType, NULL, NULL));
}
开发者ID:davidcrawford,项目名称:pyhook,代码行数:19,代码来源:pyhookmodule.c
示例6: initrtaudio
PyMODINIT_FUNC
initrtaudio(void)
{
PyEval_InitThreads();
if (PyType_Ready(&RtAudio_type) < 0)
return;
PyObject* module = Py_InitModule3("rtaudio", NULL, "RtAudio wrapper.");
if (module == NULL)
return;
Py_INCREF(&RtAudio_type);
PyModule_AddObject(module, "RtAudio", (PyObject *)&RtAudio_type);
RtAudioError = PyErr_NewException("rtaudio.RtError", NULL, NULL);
Py_INCREF(RtAudioError);
PyModule_AddObject(module, "RtError", RtAudioError);
}
开发者ID:74Labs,项目名称:rtaudio,代码行数:19,代码来源:rtaudiomodule.cpp
示例7: initrrdtool
/* Initialization function for the module */
void initrrdtool(
void)
{
PyObject *m, *d, *t;
/* Create the module and add the functions */
m = Py_InitModule("rrdtool", _rrdtool_methods);
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
SET_STRCONSTANT(d, __version__);
ErrorObject = PyErr_NewException("rrdtool.error", NULL, NULL);
PyDict_SetItemString(d, "error", ErrorObject);
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize the rrdtool module");
}
开发者ID:hidebay,项目名称:rrdtool-1.x,代码行数:20,代码来源:rrdtoolmodule.c
示例8: initlibmtp
PyMODINIT_FUNC
initlibmtp(void) {
PyObject *m;
DeviceType.tp_new = PyType_GenericNew;
if (PyType_Ready(&DeviceType) < 0)
return;
m = Py_InitModule3("libmtp", libmtp_methods, "Interface to libmtp.");
if (m == NULL) return;
MTPError = PyErr_NewException("libmtp.MTPError", NULL, NULL);
if (MTPError == NULL) return;
PyModule_AddObject(m, "MTPError", MTPError);
// Redirect stdout to get rid of the annoying message about mtpz. Really,
// who designs a library without anyway to control/redirect the debugging
// output, and hardcoded paths that cannot be changed? Compiling libmtp without the crypt use flag disables mtpz support in libmtp
/* int bak, new; */
/* fprintf(stdout, "\n"); // This is needed, without it, for some odd reason the code below causes stdout to buffer all output after it is restored, rather than using line buffering, and setlinebuf does not work. */
/* fflush(stdout); */
/* bak = dup(STDOUT_FILENO); */
/* new = open("/dev/null", O_WRONLY); */
/* dup2(new, STDOUT_FILENO); */
/* close(new); */
LIBMTP_Init();
/* fflush(stdout); */
/* dup2(bak, STDOUT_FILENO); */
/* close(bak); */
LIBMTP_Set_Debug(LIBMTP_DEBUG_NONE);
Py_INCREF(&DeviceType);
PyModule_AddObject(m, "Device", (PyObject *)&DeviceType);
PyModule_AddStringMacro(m, LIBMTP_VERSION_STRING);
PyModule_AddIntMacro(m, LIBMTP_DEBUG_NONE);
PyModule_AddIntMacro(m, LIBMTP_DEBUG_PTP);
PyModule_AddIntMacro(m, LIBMTP_DEBUG_PLST);
PyModule_AddIntMacro(m, LIBMTP_DEBUG_USB);
PyModule_AddIntMacro(m, LIBMTP_DEBUG_DATA);
PyModule_AddIntMacro(m, LIBMTP_DEBUG_ALL);
}
开发者ID:AEliu,项目名称:calibre,代码行数:43,代码来源:libmtp.c
示例9: init_sophia
PyMODINIT_FUNC
init_sophia(void)
#endif
{
static char *sophia_constant_names[] = {"SPGT", "SPGTE", "SPLT", "SPLTE",
"SPCMP", "SPPAGE", "SPMERGEWM", "SPGC", "SPMERGE", "SPGCF", "SPGROW", NULL};
static int sophia_constant_values[] = {SPGT, SPGTE, SPLT, SPLTE,
SPCMP, SPPAGE, SPMERGEWM, SPGC, SPMERGE, SPGCF, SPGROW, 0};
if (PyType_Ready(&SophiaDBType) == -1)
return PSP_NOTHING;
SophiaError = PyErr_NewException("sophia.Error", NULL, NULL);
if (!SophiaError)
return PSP_NOTHING;
#if PY_MAJOR_VERSION >= 3
PyObject *module = PyModule_Create(&_sophiamodule);
#else
PyObject *module = Py_InitModule("_sophia", NULL);
#endif
if (!module)
return PSP_NOTHING;
char **names = sophia_constant_names;
int *values = sophia_constant_values;
while (*names) {
if (PyModule_AddIntConstant(module, *names++, *values++) == -1)
return PSP_NOTHING;
}
Py_INCREF(&SophiaDBType);
Py_INCREF(SophiaError);
if (PyModule_AddObject(module, "Database", (PyObject *)&SophiaDBType) == -1 ||
PyModule_AddObject(module, "Error", SophiaError) == -1)
return PSP_NOTHING;
#if PY_MAJOR_VERSION >= 3
return module;
#endif
}
开发者ID:david-furminieux,项目名称:python-sophia,代码行数:43,代码来源:pysophia.c
示例10: psyco_errors_init
static int
psyco_errors_init(void)
{
/* the names of the exceptions here reflect the organization of the
psycopg2 module and not the fact the the original error objects
live in _psycopg */
int i;
PyObject *dict = NULL;
PyObject *str = NULL;
int rv = -1;
/* 'Error' has been defined elsewhere: only init the other classes */
Error = (PyObject *)&errorType;
for (i = 1; exctable[i].name; i++) {
if (!(dict = PyDict_New())) { goto exit; }
if (exctable[i].docstr) {
if (!(str = Text_FromUTF8(exctable[i].docstr))) { goto exit; }
if (0 != PyDict_SetItemString(dict, "__doc__", str)) { goto exit; }
Py_CLEAR(str);
}
/* can't put PyExc_StandardError in the static exctable:
* windows build will fail */
if (!(*exctable[i].exc = PyErr_NewException(
exctable[i].name,
exctable[i].base ? *exctable[i].base : PyExc_StandardError,
dict))) {
goto exit;
}
Py_CLEAR(dict);
}
rv = 0;
exit:
Py_XDECREF(str);
Py_XDECREF(dict);
return rv;
}
开发者ID:JonathanRRogers,项目名称:psycopg2,代码行数:42,代码来源:psycopgmodule.c
示例11: initsound
initsound(void)
{
Py_Initialize();
PyObject *m= Py_InitModule(MODULE_NAME, pysound_methods);
// Initialize tables
PyModule_AddStringConstant(m, "__doc__", PYMODULEDOC );
PyModule_AddStringConstant(m, "version", PYSNDVERSION );
PyModule_AddIntConstant(m, "build", PYSNDBUILD );
_EXPORT_INT(m, AFMT_MU_LAW);
_EXPORT_INT(m, AFMT_A_LAW);
_EXPORT_INT(m, AFMT_IMA_ADPCM);
_EXPORT_INT(m, AFMT_U8);
_EXPORT_INT(m, AFMT_S16_LE);
_EXPORT_INT(m, AFMT_S16_BE);
_EXPORT_INT(m, AFMT_S8);
_EXPORT_INT(m, AFMT_U16_LE);
_EXPORT_INT(m, AFMT_U16_BE);
_EXPORT_INT(m, AFMT_MPEG);
_EXPORT_INT(m, AFMT_AC3);
_EXPORT_INT(m, AFMT_S16_NE);
g_cErr = PyErr_NewException(MODULE_NAME".SoundError", NULL, NULL);
if( g_cErr != NULL)
PyModule_AddObject(m, "SoundError", g_cErr );
PyISoundType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&PyISoundType);
PyModule_AddObject(m, INPUT_NAME, (PyObject *)&PyISoundType);
PySoundType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&PySoundType);
PyModule_AddObject(m, OUTPUT_NAME, (PyObject *)&PySoundType);
ResamplerType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&ResamplerType);
PyModule_AddObject(m, RESAMPLER_NAME, (PyObject *)&ResamplerType);
AnalyzerType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&AnalyzerType);
PyModule_AddObject(m, ANALYZER_NAME, (PyObject *)&AnalyzerType);
MixerType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&MixerType);
PyModule_AddObject(m, MIXER_NAME, (PyObject *)&MixerType);
}
开发者ID:gromaudio,项目名称:dashtest,代码行数:42,代码来源:sound.cpp
示例12: PyInit_zlib
PyMODINIT_FUNC
PyInit_zlib(void)
{
PyObject *m, *ver;
Comptype.ob_type = &PyType_Type;
Decomptype.ob_type = &PyType_Type;
m = Py_InitModule4("zlib", zlib_methods,
zlib_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
if (m == NULL)
return;
ZlibError = PyErr_NewException("zlib.error", NULL, NULL);
if (ZlibError != NULL) {
Py_INCREF(ZlibError);
PyModule_AddObject(m, "error", ZlibError);
}
PyModule_AddIntConstant(m, "MAX_WBITS", MAX_WBITS);
PyModule_AddIntConstant(m, "DEFLATED", DEFLATED);
PyModule_AddIntConstant(m, "DEF_MEM_LEVEL", DEF_MEM_LEVEL);
PyModule_AddIntConstant(m, "Z_BEST_SPEED", Z_BEST_SPEED);
PyModule_AddIntConstant(m, "Z_BEST_COMPRESSION", Z_BEST_COMPRESSION);
PyModule_AddIntConstant(m, "Z_DEFAULT_COMPRESSION", Z_DEFAULT_COMPRESSION);
PyModule_AddIntConstant(m, "Z_FILTERED", Z_FILTERED);
PyModule_AddIntConstant(m, "Z_HUFFMAN_ONLY", Z_HUFFMAN_ONLY);
PyModule_AddIntConstant(m, "Z_DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY);
PyModule_AddIntConstant(m, "Z_FINISH", Z_FINISH);
PyModule_AddIntConstant(m, "Z_NO_FLUSH", Z_NO_FLUSH);
PyModule_AddIntConstant(m, "Z_SYNC_FLUSH", Z_SYNC_FLUSH);
PyModule_AddIntConstant(m, "Z_FULL_FLUSH", Z_FULL_FLUSH);
ver = PyString_FromString(ZLIB_VERSION);
if (ver != NULL)
PyModule_AddObject(m, "ZLIB_VERSION", ver);
PyModule_AddStringConstant(m, "__version__", "1.0");
#ifdef WITH_THREAD
zlib_lock = PyThread_allocate_lock();
#endif /* WITH_THREAD */
}
开发者ID:Charlian,项目名称:python-cobra,代码行数:42,代码来源:zlibmodule.c
示例13: PyInit_cstuff
PyMODINIT_FUNC PyInit_cstuff(void) {
PyObject *module;
module = PyModule_Create(&cstuff_module);
if (module == NULL) {
return NULL;
}
if (PyType_Ready(&cstuff_DirectionMapType) < 0) {
return NULL;
}
CStuffError = PyErr_NewException("cstuff.CStuffError", NULL, NULL);
Py_INCREF(CStuffError);
PyModule_AddObject(module, "CStuffError", CStuffError);
Py_INCREF(&cstuff_DirectionMapType);
PyModule_AddObject(module, "DirectionMap", (PyObject *)&cstuff_DirectionMapType);
return module;
}
开发者ID:fluxid,项目名称:flantob,代码行数:20,代码来源:cstuff.c
示例14: PyInit__simpleaudio
PyMODINIT_FUNC
PyInit__simpleaudio(void)
{
PyObject *m;
m = PyModule_Create(&_simpleaudio_module);
if (m == NULL)
return NULL;
sa_python_error = PyErr_NewException("_simpleaudio.SimpleaudioError", NULL, NULL);
Py_INCREF(sa_python_error);
PyModule_AddObject(m, "SimpleaudioError", sa_python_error);
/* initialize the list head mutex */
play_list_head.mutex = create_mutex();
dbg1("init'd list head at %p\n", &play_list_head);
return m;
}
开发者ID:hamiltron,项目名称:py-simple-audio,代码行数:20,代码来源:simpleaudio.c
示例15: initcd
initcd(void)
{
Py_Initialize();
g_iMaxCDROMIndex= -1;
PyObject *m = Py_InitModule("cd", pycd_methods);
PyModule_AddStringConstant( m, "__doc__", (char*)PYDOC );
PyModule_AddStringConstant( m, "version", (char*)PYCDVERSION );
PyModule_AddIntConstant( m, "build", PYCDBUILD );
INT_CONSTANT( SEEK_SET );
INT_CONSTANT( SEEK_END );
INT_CONSTANT( SEEK_CUR );
g_cErr = PyErr_NewException(MODULE_NAME".CDError", NULL, NULL);
if( g_cErr != NULL)
PyModule_AddObject(m, "CDError", g_cErr );
PyCDType.ob_type = &PyType_Type;
Py_INCREF((PyObject *)&PyCDType);
PyModule_AddObject(m, "CD", (PyObject *)&PyCDType);
}
开发者ID:gromaudio,项目名称:dashtest,代码行数:20,代码来源:cd.cpp
示例16: inithunspell
CALIBRE_MODINIT_FUNC
inithunspell(void) {
PyObject *mod;
// Create the module
mod = Py_InitModule3("hunspell", NULL,
"A wrapper for the hunspell spell checking library");
if (mod == NULL) return;
HunspellError = PyErr_NewException((char*)"hunspell.HunspellError", NULL, NULL);
if (HunspellError == NULL) return;
PyModule_AddObject(mod, "HunspellError", HunspellError);
// Fill in some slots in the type, and make it ready
DictionaryType.tp_new = PyType_GenericNew;
if (PyType_Ready(&DictionaryType) < 0) return;
// Add the type to the module.
Py_INCREF(&DictionaryType);
PyModule_AddObject(mod, "Dictionary", (PyObject *)&DictionaryType);
}
开发者ID:MarioJC,项目名称:calibre,代码行数:20,代码来源:hunspell_wrapper.cpp
示例17: initketama
PyMODINIT_FUNC initketama(void) {
PyObject *m;
if (PyType_Ready(&pyketama_ContinuumType) < 0) {
return;
}
if (!(m = Py_InitModule3("ketama", ketamaMethods,
"Python extension for calling libketama functions."))) {
return;
}
pyketama_error = PyErr_NewException("ketama.KetamaError", NULL, NULL);
Py_INCREF(pyketama_error);
PyModule_AddObject(m, "KetamaError", pyketama_error);
Py_INCREF(&pyketama_ContinuumType);
PyModule_AddObject(m, "Continuum", (PyObject *)&pyketama_ContinuumType);
}
开发者ID:wayfair,项目名称:ketama,代码行数:20,代码来源:ketamamodule.c
示例18: initscheme
PyMODINIT_FUNC initscheme(void){
PyObject *m;
m = Py_InitModule("scheme", SchemeMethods);
if (m == NULL)
return;
SchemeError = PyErr_NewException("scheme.error", NULL, NULL);
Py_INCREF(SchemeError);
PyModule_AddObject(m, "error", SchemeError);
VM_Type.tp_new = PyType_GenericNew;
if (PyType_Ready(VM_Type) < 0)
return;
Py_INCREF(&VM_Type);
PyModule_AddObject(m, "VM", (PyObject *)&VM_Type);
}
开发者ID:bluemoon,项目名称:Godel,代码行数:20,代码来源:scheme.c
示例19: initJitCore_x86
PyMODINIT_FUNC
initJitCore_x86(void)
{
PyObject *m;
if (PyType_Ready(&JitCpuType) < 0)
return;
m = Py_InitModule("JitCore_x86", JitCore_x86_Methods);
if (m == NULL)
return;
JitCore_x86_Error = PyErr_NewException("JitCore_x86.error", NULL, NULL);
Py_INCREF(JitCore_x86_Error);
PyModule_AddObject(m, "error", JitCore_x86_Error);
Py_INCREF(&JitCpuType);
PyModule_AddObject(m, "JitCpu", (PyObject *)&JitCpuType);
}
开发者ID:chenji1978,项目名称:miasm,代码行数:20,代码来源:JitCore_x86.c
示例20: initfftpack_lite
PyMODINIT_FUNC initfftpack_lite(void)
{
PyObject *m, *d;
/* Create the module and add the functions */
m = Py_InitModule4("fftpack_lite", fftpack_methods,
fftpack_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
/* Import the array object */
import_array();
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
ErrorObject = PyErr_NewException("fftpack.error", NULL, NULL);
PyDict_SetItemString(d, "error", ErrorObject);
/* XXXX Add constants here */
}
开发者ID:chadnetzer,项目名称:numpy-gaurdro,代码行数:20,代码来源:fftpack_litemodule.c
注:本文中的PyErr_NewException函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论