A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-list/2001-April/080661.html below:

Redirecting STDIO/STDERR in an python embedded application

Redirecting STDIO/STDERR in an python embedded application Redirecting STDIO/STDERR in an python embedded applicationKarl Bellve Karl.Bellve at umassmed.edu
Mon Apr 2 16:51:55 EDT 2001
I am trying to redirect Pythons STDIO/STDERR within my application. Here
is the python code:

PyRun_SimpleString("class my_stdout:\n"
		   "    def write(self,string):\"
		   "         image.stdout(string)\n"
		   "import sys\n"
	           "sys.stdout = my_stdout()\n");

And here is the C++ code:

static struct _object *s_stdout(PyObject *self, PyObject *args)
{

	char *string = NULL;

	if (!PyArg_ParseTuple(args, "s" &string))
		return Py_None;
	/* some code

	return Py_None
}

The function s_stdout is being called but PyArg_ParseTuple is failing. I
believe it doesn't think there is a string in the "args" Object. When I
look at the "args" object, it claims it is a "string" but I don't
actually see any text associated with it, other than "string." Any
ideas?



-- 
Cheers,



Karl Bellve


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4