/** * @deprecated As of Jython 2.5, use {@link PyException#match} instead. */ @Deprecated public static boolean matchException(PyException pye, PyObject exc) { return pye.match(exc); }
@Override public PyObject __finditem__(PyObject key) { try { return deque___getitem__(key); } catch (PyException pe) { if (pe.match(Py.KeyError)) { return null; } throw pe; } }
public static boolean hasattr(PyObject obj, PyObject nameObj) { String name = asName(nameObj, "hasattr"); try { return obj.__findattr__(name) != null; } catch (PyException pye) { if (pye.match(Py.KeyboardInterrupt) || pye.match(Py.SystemExit)) { throw pye; } //Otherwise swallow exception. } return false; }
public void delglobal(String index) { try { f_globals.__delitem__(index); } catch (PyException pye) { if (pye.match(Py.KeyError)) { throw Py.NameError(String.format(GLOBAL_NAME_ERROR_MSG, index)); } throw pye; } }
public static PyObject vars(PyObject o) { try { return o.__getattr__("__dict__"); } catch (PyException e) { if (e.match(Py.AttributeError)) { throw Py.TypeError("vars() argument must have __dict__ attribute"); } throw e; } }
public static PyObject iter(PyObject seq, String message) { try { return seq.__iter__(); } catch (PyException exc) { if (exc.match(Py.TypeError)) { throw Py.TypeError(message); } throw exc; } } private static IdImpl idimpl = new IdImpl();
public static void unsetenv(String key) { // import os; try: del os.environ[key]; except KeyError: pass PyObject environ = imp.load("os").__getattr__("environ"); try { environ.__delitem__(key); } catch (PyException pye) { if (!pye.match(Py.KeyError)) { throw pye; } } }
@Override public PyObject __int__() { try { return Py.newInteger(atoi(10)); } catch (PyException e) { if (e.match(Py.OverflowError)) { return atol(10); } throw e; } }
protected void setsliceIterable(int start, int stop, int step, PyObject value) { PyObject[] seq; try { seq = Py.make_array(value); } catch (PyException pye) { if (pye.match(Py.TypeError)) { throw Py.TypeError("can only assign an iterable"); } throw pye; } setslicePySequence(start, stop, step, new PyList(seq)); }
public PyObject __finditem__(PyObject key) { // ??? PyType self_type=getType(); PyObject impl=self_type.lookup("__getitem__"); if (impl!=null) try { return impl.__get__(this,self_type).__call__(key); } catch (PyException exc) { if (exc.match(Py.LookupError)) return null; throw exc; } return super.__finditem__(key); }
public PyObject __finditem__(PyObject key) { // ??? PyType self_type=getType(); PyObject impl=self_type.lookup("__getitem__"); if (impl!=null) try { return impl.__get__(this,self_type).__call__(key); } catch (PyException exc) { if (exc.match(Py.LookupError)) return null; throw exc; } return super.__finditem__(key); }
public PyObject __finditem__(PyObject key) { // ??? PyType self_type=getType(); PyObject impl=self_type.lookup("__getitem__"); if (impl!=null) try { return impl.__get__(this,self_type).__call__(key); } catch (PyException exc) { if (exc.match(Py.LookupError)) return null; throw exc; } return super.__finditem__(key); }
public PyObject __finditem__(PyObject key) { // ??? PyType self_type=getType(); PyObject impl=self_type.lookup("__getitem__"); if (impl!=null) try { return impl.__get__(this,self_type).__call__(key); } catch (PyException exc) { if (exc.match(Py.LookupError)) return null; throw exc; } return super.__finditem__(key); }
public PyObject __finditem__(int key) { PyType self_type=getType(); PyObject impl=self_type.lookup("__getitem__"); if (impl!=null) try { return impl.__get__(this,self_type).__call__(new PyInteger(key)); } catch (PyException exc) { if (exc.match(Py.LookupError)) return null; throw exc; } return super.__finditem__(key); }
public PyObject __finditem__(int key) { PyType self_type=getType(); PyObject impl=self_type.lookup("__getitem__"); if (impl!=null) try { return impl.__get__(this,self_type).__call__(new PyInteger(key)); } catch (PyException exc) { if (exc.match(Py.LookupError)) return null; throw exc; } return super.__finditem__(key); }
public PyObject __finditem__(int key) { PyType self_type=getType(); PyObject impl=self_type.lookup("__getitem__"); if (impl!=null) try { return impl.__get__(this,self_type).__call__(new PyInteger(key)); } catch (PyException exc) { if (exc.match(Py.LookupError)) return null; throw exc; } return super.__finditem__(key); }
public PyObject __finditem__(int key) { PyType self_type=getType(); PyObject impl=self_type.lookup("__getitem__"); if (impl!=null) try { return impl.__get__(this,self_type).__call__(new PyInteger(key)); } catch (PyException exc) { if (exc.match(Py.LookupError)) return null; throw exc; } return super.__finditem__(key); }