Implementation of the Python exceptions module and the IronPython/CLR exception mapping mechanism. The exception module is the parent module for all Python exception classes and therefore is built-in to IronPython.dll instead of IronPython.Modules.dll. The exception mapping mechanism is exposed as internal surface area available to only IronPython / IronPython.Modules.dll. The actual exceptions themselves are all public. Because the oddity of the built-in exception types all sharing the same physical layout (see also PythonExceptions.BaseException) some classes are defined as classes w/ their proper name and some classes are defined as PythonType fields. When a class is defined for convenience their's also an _TypeName version which is the PythonType.
예제 #1
0
        public int GetExitCode(out object otherCode) {
            otherCode = null;
            object pyObj = PythonExceptions.ToPython(this);

            object args;
            PythonTuple t;

            if (!PythonOps.TryGetBoundAttr(pyObj, "args", out args) ||
                (t = args as PythonTuple) == null ||
                t.__len__() == 0) {
                return 0;
            } else if (Builtin.isinstance(t[0], TypeCache.Int32)) {
                return Converter.ConvertToInt32(t[0]);
            }

            otherCode = t[0];
            return 1;
        }