Package org.python.core

Examples of org.python.core.PyException


        final private int marker() {
            for (int k = stackTop-1; k >= 0; k--)
                if (stack[k] == mark)
                    return stackTop-k-1;
            throw new PyException(UnpicklingError,
                        "Inputstream corrupt, marker not found");
        }
View Full Code Here


                        "Inputstream corrupt, marker not found");
        }


        final private void load_eof() {
            throw new PyException(Py.EOFError);
        }
View Full Code Here

            load_persid(pop());
        }

        final private void load_persid(PyObject pid) {
            if (persistent_load == null) {
                throw new PyException(UnpicklingError,
                                      "A load persistent id instruction was encountered,\n"
                                      + "but no persistent_load function was specified.");
            }

            if (persistent_load instanceof PyList) {
View Full Code Here


        final private PyObject find_class(String module, String name) {
            if (find_global != null) {
               if (find_global == Py.None)
                   throw new PyException(UnpicklingError,
                         "Global and instance pickles are not supported.");
               return find_global.__call__(new PyString(module), new PyString(name));
            }

            PyObject modules = Py.getSystemState().modules;
            PyObject mod = modules.__finditem__(module.intern());
            if (mod == null) {
                mod = importModule(module);
            }
            PyObject global = mod.__findattr__(name.intern());
            if (global == null) {
                throw new PyException(Py.SystemError,
                          "Failed to import class " + name + " from module " +
                          module);
            }
            return global;
        }
View Full Code Here

        private void load_ext(int length) {
            int code = read_binint(length);
            // TODO: support _extension_cache
            PyObject key = inverted_registry.get(Py.newInteger(code));
            if (key == null) {
                throw new PyException(Py.ValueError, "unregistered extension code " + code);
            }
            String module = key.__finditem__(0).toString();
            String name = key.__finditem__(1).toString();
            push(find_class(module, name));
        }
View Full Code Here

        final private void load_get() {
            String py_str = file.readlineNoNl();
            PyObject value = memo.get(py_str);
            if (value == null) {
                throw new PyException(BadPickleGet, py_str);
            }
            push(value);
        }
View Full Code Here

        final private void load_binget() {
            String py_key = String.valueOf((int)file.read(1).charAt(0));
            PyObject value = memo.get(py_key);
            if (value == null) {
                throw new PyException(BadPickleGet, py_key);
            }
            push(value);
        }
View Full Code Here

        final private void load_long_binget() {
            int i = read_binint();
            String py_key = String.valueOf(i);
            PyObject value = memo.get(py_key);
            if (value == null) {
                throw new PyException(BadPickleGet, py_key);
            }
            push(value);
        }
View Full Code Here

                slotstate = temp.__getitem__(1);
            }

            if (state != Py.None) {
                if (!(state instanceof PyDictionary)) {
                    throw new PyException(UnpicklingError, "state is not a dictionary");
                }
                PyObject dict = inst.__getattr__("__dict__");
                for (PyObject item : ((PyDictionary)state).iteritems().asIterable()) {
                    dict.__setitem__(item.__getitem__(0), item.__getitem__(1));
                }
            }

            // Also set instance attributes from the slotstate dict (if any).
            if (slotstate != null) {
                if (!(slotstate instanceof PyDictionary)) {
                    throw new PyException(UnpicklingError, "slot state is not a dictionary");
                }
                for (PyObject item : ((PyDictionary)slotstate).iteritems().asIterable()) {
                    inst.__setattr__(PyObject.asName(item.__getitem__(0)),
                                     item.__getitem__(1));
                }
View Full Code Here

    public static volatile int field_limit = 128 * 1024;

    /** _csv.Error exception. */
    public static final PyObject Error = Py.makeClass("Error", Py.Exception, exceptionNamespace());
    public static PyException Error(String message) {
        return new PyException(Error, message);
    }
View Full Code Here

TOP

Related Classes of org.python.core.PyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.