| OLD | NEW |
|---|---|
| 1 // Copyright (c) Corporation for National Research Initiatives | 1 // Copyright (c) Corporation for National Research Initiatives |
| 2 package org.python.core; | 2 package org.python.core; |
| 3 | 3 |
| 4 import java.io.ByteArrayInputStream; | 4 import java.io.ByteArrayInputStream; |
| 5 import java.io.ByteArrayOutputStream; | 5 import java.io.ByteArrayOutputStream; |
| 6 import java.io.File; | 6 import java.io.File; |
| 7 import java.io.FileOutputStream; | 7 import java.io.FileOutputStream; |
| 8 import java.io.InputStream; | 8 import java.io.InputStream; |
| 9 import java.io.ObjectStreamException; | 9 import java.io.ObjectStreamException; |
| 10 import java.io.OutputStream; | 10 import java.io.OutputStream; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 205 |
| 206 public static PyException NameError(String message) { | 206 public static PyException NameError(String message) { |
| 207 return new PyException(Py.NameError, message); | 207 return new PyException(Py.NameError, message); |
| 208 } | 208 } |
| 209 public static PyObject UnboundLocalError; | 209 public static PyObject UnboundLocalError; |
| 210 | 210 |
| 211 public static PyException UnboundLocalError(String message) { | 211 public static PyException UnboundLocalError(String message) { |
| 212 return new PyException(Py.UnboundLocalError, message); | 212 return new PyException(Py.UnboundLocalError, message); |
| 213 } | 213 } |
| 214 public static PyObject SystemExit; | 214 public static PyObject SystemExit; |
| 215 | |
|
fwierzbicki
2008/08/04 13:42:57
We should comment this as being experimental.
| |
| 216 /** | |
| 217 * Jython-specific exception for restarting the interpreter. Currently | |
| 218 * supported only by jython.java, when executing a file (i.e, | |
| 219 * non-interactive mode) | |
| 220 */ | |
| 221 public static PyObject SystemRestart; | |
| 222 public static PyException SystemRestart() { | |
| 223 return new PyException(Py.SystemRestart); | |
| 224 } | |
| 225 | |
| 215 | 226 |
| 216 static void maybeSystemExit(PyException exc) { | 227 static void maybeSystemExit(PyException exc) { |
| 217 if (Py.matchException(exc, Py.SystemExit)) { | 228 if (Py.matchException(exc, Py.SystemExit)) { |
| 218 PyObject value = exc.value; | 229 PyObject value = exc.value; |
| 219 if (PyException.isExceptionInstance(exc.value)) { | 230 if (PyException.isExceptionInstance(exc.value)) { |
| 220 value = value.__findattr__("code"); | 231 value = value.__findattr__("code"); |
| 221 } | 232 } |
| 222 Py.getSystemState().callExitFunc(); | 233 Py.getSystemState().callExitFunc(); |
| 223 if (value instanceof PyInteger) { | 234 if (value instanceof PyInteger) { |
| 224 System.exit(((PyInteger) value).getValue()); | 235 System.exit(((PyInteger) value).getValue()); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 dict.__setitem__(name, tmp); | 709 dict.__setitem__(name, tmp); |
| 699 return tmp; | 710 return tmp; |
| 700 } | 711 } |
| 701 | 712 |
| 702 static void initClassExceptions(PyObject dict) { | 713 static void initClassExceptions(PyObject dict) { |
| 703 PyObject exc = imp.load("exceptions"); | 714 PyObject exc = imp.load("exceptions"); |
| 704 | 715 |
| 705 BaseException = initExc("BaseException", exc, dict); | 716 BaseException = initExc("BaseException", exc, dict); |
| 706 Exception = initExc("Exception", exc, dict); | 717 Exception = initExc("Exception", exc, dict); |
| 707 SystemExit = initExc("SystemExit", exc, dict); | 718 SystemExit = initExc("SystemExit", exc, dict); |
| 719 SystemRestart = initExc("SystemRestart", exc, dict); | |
| 708 StopIteration = initExc("StopIteration", exc, dict); | 720 StopIteration = initExc("StopIteration", exc, dict); |
| 709 GeneratorExit = initExc("GeneratorExit", exc, dict); | 721 GeneratorExit = initExc("GeneratorExit", exc, dict); |
| 710 StandardError = initExc("StandardError", exc, dict); | 722 StandardError = initExc("StandardError", exc, dict); |
| 711 KeyboardInterrupt = initExc("KeyboardInterrupt", exc, dict); | 723 KeyboardInterrupt = initExc("KeyboardInterrupt", exc, dict); |
| 712 ImportError = initExc("ImportError", exc, dict); | 724 ImportError = initExc("ImportError", exc, dict); |
| 713 EnvironmentError = initExc("EnvironmentError", exc, dict); | 725 EnvironmentError = initExc("EnvironmentError", exc, dict); |
| 714 IOError = initExc("IOError", exc, dict); | 726 IOError = initExc("IOError", exc, dict); |
| 715 OSError = initExc("OSError", exc, dict); | 727 OSError = initExc("OSError", exc, dict); |
| 716 EOFError = initExc("EOFError", exc, dict); | 728 EOFError = initExc("EOFError", exc, dict); |
| 717 RuntimeError = initExc("RuntimeError", exc, dict); | 729 RuntimeError = initExc("RuntimeError", exc, dict); |
| (...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2036 if (container == null) { | 2048 if (container == null) { |
| 2037 return this; | 2049 return this; |
| 2038 } | 2050 } |
| 2039 return new PyMethod(this, container, wherefound); | 2051 return new PyMethod(this, container, wherefound); |
| 2040 } | 2052 } |
| 2041 | 2053 |
| 2042 public boolean _doset(PyObject container) { | 2054 public boolean _doset(PyObject container) { |
| 2043 throw Py.TypeError("java function not settable: " + method.getName()); | 2055 throw Py.TypeError("java function not settable: " + method.getName()); |
| 2044 } | 2056 } |
| 2045 } | 2057 } |
| OLD | NEW |