Exemple #1
0
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);
}
Exemple #2
0
PyObject *
PyErr_Format(PyObject *exception, const char *format, ...)
{
    va_list vargs;
    PyObject* string;

#ifdef HAVE_STDARG_PROTOTYPES
    va_start(vargs, format);
#else
    va_start(vargs);
#endif

    if( Py_ErrFormatFlag == 1 )
    {
        string = PyString_FromFormatV(format, vargs);
    }
    else
    {
        Py_INCREF(Py_None);
        string = Py_None;
    }

    PyErr_SetObject(exception, string);
    Py_XDECREF(string);
    va_end(vargs);
    return NULL;
}
Exemple #3
0
EXPORT ICUException::ICUException(UErrorCode status, char *format, ...)
{
    ICUException::code = PyInt_FromLong((long) status);

    va_list ap;
    va_start(ap, format);
    ICUException::msg = PyString_FromFormatV(format, ap);
    va_end(ap);
}
Exemple #4
0
PyObject* fromFormat(const char* format, ...)
{
    va_list argp;
    va_start(argp, format);
    PyObject* result = 0;
#ifdef IS_PY3K
    result = PyUnicode_FromFormatV(format, argp);
#else
    result = PyString_FromFormatV(format, argp);
#endif
    va_end(argp);
    return result;
}
Exemple #5
0
/* Log a message. Returns -1 on error, 0 on success. */
static int
debug_print(PyObject *logfunc, const char *format, ...)
{
	/* Sanity check. Should not happen. */
	if (!logfunc)
		return -1;
	va_list vargs;
	va_start(vargs, format);
	PyObject *message = PyString_FromFormatV(format, vargs);
	va_end(vargs);
	if (!message)
		return -1;
	PyObject *result = PyObject_CallFunctionObjArgs(logfunc, message, NULL);
	Py_DECREF(message);
	return result ? 0 : -1;
}
Exemple #6
0
PyObject *
PyErr_Format(PyObject *exception, const char *format, ...)
{
//	puts("PyErr_Format");
//	puts(format);
	va_list vargs;
	PyObject* string;

#ifdef HAVE_STDARG_PROTOTYPES
	va_start(vargs, format);
#else
	va_start(vargs);
#endif

	string = PyString_FromFormatV(format, vargs);
//	puts(PyString_AS_STRING(string));
	PyErr_SetObject(exception, string);
	Py_XDECREF(string);
	va_end(vargs);
	return NULL;
}