Python.Runtime.Exceptions.ExceptionMatches C# (CSharp) Method

ExceptionMatches() public static method

ExceptionMatches Method
Returns true if the current Python exception matches the given Python object. This is a wrapper for PyErr_ExceptionMatches.
public static ExceptionMatches ( IntPtr ob ) : bool
ob System.IntPtr
return bool
        public static bool ExceptionMatches(IntPtr ob)
        {
            return Runtime.PyErr_ExceptionMatches(ob) != 0;
        }

Same methods

Exceptions::ExceptionMatches ( IntPtr exc, IntPtr ob ) : bool

Usage Example

Example #1
0
        protected override void OnSave(InterDomainContext context)
        {
            base.OnSave(context);
            System.Diagnostics.Debug.Assert(dict == GetObjectDict(pyHandle));
            foreach (var attr in cache.Values)
            {
                Runtime.XIncref(attr.pyHandle);
            }
            // Decref twice in tp_clear, equilibrate them.
            Runtime.XIncref(dict);
            Runtime.XIncref(dict);
            // destroy the cache(s)
            foreach (var pair in cache)
            {
                if ((Runtime.PyDict_DelItemString(DictRef, pair.Key) == -1) &&
                    (Exceptions.ExceptionMatches(Exceptions.KeyError)))
                {
                    // Trying to remove a key that's not in the dictionary
                    // raises an error. We don't care about it.
                    Runtime.PyErr_Clear();
                }
                else if (Exceptions.ErrorOccurred())
                {
                    throw new PythonException();
                }
                pair.Value.DecrRefCount();
            }

            cache.Clear();
        }
All Usage Examples Of Python.Runtime.Exceptions::ExceptionMatches