#ifndef PYLOGGER_H
#define PYLOGGER_H

#include "Python.h"
#include <string>
#include "cantera/base/logger.h"

namespace Cantera
{

/// Logger for Python.
/// @ingroup textlogs
class Py_Logger : public Logger
{
public:
    Py_Logger() {
        PyRun_SimpleString("import sys");
    }
    virtual ~Py_Logger() {}

    virtual void write(const std::string& s) {
        std::string ss = "sys.stdout.write(\"\"\"";
        ss += s;
        ss += "\"\"\")";
        PyRun_SimpleString(ss.c_str());
        PyRun_SimpleString("sys.stdout.flush()");
    }

    virtual void error(const std::string& msg) {
        std::string err = "raise Exception(\"\"\""+msg+"\"\"\")";
        PyRun_SimpleString(err.c_str());
    }
};
}

#endif

#ifndef PYLOGGER_H
#define PYLOGGER_H

#include "Python.h"
#include <string>
#include "cantera/base/logger.h"

namespace Cantera
{

/// Logger for Python.
/// @ingroup textlogs
class Py_Logger : public Logger
{
public:
    Py_Logger() {
        PyRun_SimpleString("import sys");
    }
    virtual ~Py_Logger() {}

    virtual void write(const std::string& s) {
        std::string ss = "sys.stdout.write(\"\"\"";
        ss += s;
        ss += "\"\"\")";
        PyRun_SimpleString(ss.c_str());
        PyRun_SimpleString("sys.stdout.flush()");
    }

    virtual void error(const std::string& msg) {
        std::string err = "raise \""+msg+"\"";
        PyRun_SimpleString((char*)err.c_str());
    }
};
}

#endif

--- 
+++ 
@@ -27,8 +27,8 @@
     }
 
     virtual void error(const std::string& msg) {
-        std::string err = "raise \""+msg+"\"";
-        PyRun_SimpleString((char*)err.c_str());
+        std::string err = "raise Exception(\"\"\""+msg+"\"\"\")";
+        PyRun_SimpleString(err.c_str());
     }
 };
 }
Fix Py_Logger to raise instances of Exception instead of strings

Raising string exceptions was removed in Python 2.6

git-svn-id: e76dbe14710aecee1ad27675521492cea2578c83@1932 02a645c2-efd0-11dd-984d-ab748d24aa7e
