Skip to main content
gamedev.net
🔒 Locked

boost::python embedding error finding

Started by CoMaNdore 1 reply 1.1k views
Original Post
CoMaNdore
CoMaNdore
Hey Im creating a game using python as a embedded scripting language. ( using boost.python to intergrate python ) Now what I want is to get the information that PyErr_Print() prints. As I dont got any console I find it hard to get this information. Please help me.. [Edited by - CoMaNdore on June 2, 2006 5:16:49 PM]
Me
Kylotan
Kylotan
Did you try putting PyErr_Print into Google? It seems you are not the first to ask this, and there seem to be a few comments about redirecting the error output.
CoMaNdore
CoMaNdore
Hey stupid of me to just browse the python.boost pages when this is a python problem. Anyway I wanted to do this from the c++ side of things

Here is how it works (it do need some polish but anyway.. )
	class PythonStdoutCatcher	{		public:			void write( std::string p_Data )			{				m_Data += p_Data;			}			std::string GetData()			{				return( m_Data );			}			void Catch()			{				m_Data = "";				object sys_obj( handle<>( PyImport_ImportModule( "sys" ) ) );				sys_obj.attr( "stdout" ) = (object)*this;			}		private:			static std::string m_Data;	};// into boostBOOST_PYTHON_MODULE( testmod ){	class_<StdoutCatcher>( "StdoutCatcher" )		.def( "write", &StdoutCatcher::write )		.def( "GetData", &StdoutCatcher::GetData )	;};//usage:StdoutCatcher	sc;sc.Catch();// end of app// logger is my log class use whatever you wantLogger::Text( sc.GetData() );


[Edited by - CoMaNdore on June 9, 2006 12:52:13 PM]
Me

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.