コード例 #1
0
ファイル: PyException.cs プロジェクト: sgfgaming/beliEVE
        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);
        }
コード例 #2
0
ファイル: PyException.cs プロジェクト: sgfgaming/beliEVE
        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");
            }
        }