MCPcopy Create free account
hub / github.com/SamuraiT/mecab-python3 / SWIG_Python_AddErrMesg

Function SWIG_Python_AddErrMesg

src/MeCab/MeCab_wrap.cpp:2473–2499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2471#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
2472
2473SWIGRUNTIME int
2474SWIG_Python_AddErrMesg(const char* mesg, int infront)
2475{
2476 if (PyErr_Occurred()) {
2477 PyObject *type = 0;
2478 PyObject *value = 0;
2479 PyObject *traceback = 0;
2480 PyErr_Fetch(&type, &value, &traceback);
2481 if (value) {
2482 PyObject *old_str = PyObject_Str(value);
2483 const char *tmp = SWIG_Python_str_AsChar(old_str);
2484 const char *errmesg = tmp ? tmp : "Invalid error message";
2485 Py_XINCREF(type);
2486 PyErr_Clear();
2487 if (infront) {
2488 PyErr_Format(type, "%s %s", mesg, errmesg);
2489 } else {
2490 PyErr_Format(type, "%s %s", errmesg, mesg);
2491 }
2492 SWIG_Python_str_DelForPy3(tmp);
2493 Py_DECREF(old_str);
2494 }
2495 return 1;
2496 } else {
2497 return 0;
2498 }
2499}
2500
2501SWIGRUNTIME int
2502SWIG_Python_ArgFail(int argnum)

Callers 1

SWIG_Python_ArgFailFunction · 0.85

Calls 1

SWIG_Python_str_AsCharFunction · 0.85

Tested by

no test coverage detected