PyObject_CallMethod - not generating errors to stderr

Paul Miller paul at fxtech.com
Tue Feb 25 12:02:21 EST 2003


I am using PyObject_CallMethod to call a method on an object written in
Python.

If a compiler error happens in the function that is called, it simply
returns NULL, but does not seem to send the standard Python error messages
to the sys.stderr object. So I can find out that an error occurred but I
don't see what the error is in my built-in console.

Background info: I have an interactive console that redirects sys.stdout
and sys.stderr to it, using the well-known trick of defining built-in
stdout and stderr classes which write to C functions, and then replace the
sys.stderr and sys.stdout objects.

For example:

class MyObject(BaseObject):
	def foo(self):
		print "Hello"	# works
		sys.stderr.write("Hello\n") 	# works
		# the next line should generate an error and output,
		# to stderr, but doesn't
		bar

Any ideas?






More information about the Python-list mailing list