Beispiel #1
0
        public PyException(IntPtr type, IntPtr value, IntPtr traceback)
        {
            TypeObject      = new PyObject(type);
            ValueObject     = new PyObject(value);
            TracebackObject = new PyObject(traceback);
            TypeObject.IncRef();
            ValueObject.IncRef();
            TracebackObject.IncRef();

            Type = TypeObject.GetString("__name__");
            if (ValueObject.IsString)
            {
                Value = PyString.GetValueInternal(ValueObject.Pointer);
            }
            else if (ValueObject.HasAttr("message"))
            {
                Value = ValueObject.GetString("message");
            }
            else // use Py_Repr to atleast get some information
            {
                Value = ValueObject.ToString();
            }

            CallStack = new List <PyTraceback>(5);
            var cur = TracebackObject;

            while (cur != null && cur.IsValid && !cur.IsNone)
            {
                CallStack.Add(new PyTraceback(cur));
                cur = cur.Get("tb_next");
            }
        }
Beispiel #2
0
 protected void Initialize()
 {
     if (!Initialized)
     {
         Module = new PyObject(Python.InitModule(Name, Methods.ToArray()), ReferenceType.Borrowed);
         Module.IncRef();
         Initialized = true;
     }
 }
Beispiel #3
0
        public PyCode(PyObject code)
        {
            _code = code;
            code.IncRef();

            RawBytecode = code.GetRaw("co_code");
            Name        = code.GetString("co_name");
            File        = code.GetString("co_filename");
            Bytecode    = new PyBytecode(this);
        }
Beispiel #4
0
 internal PyTraceback(PyObject trace)
 {
     _trace = trace;
     trace.IncRef();
 }
Beispiel #5
0
 internal PyStackFrame(PyObject frame)
 {
     _frame = frame;
     frame.IncRef();
 }