From: Finn B. <bc...@us...> - 2001-02-22 11:09:37
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv5517 Modified Files: PySystemState.java Py.java Log Message: Added warning frame work (pep-0230). Index: PySystemState.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PySystemState.java,v retrieving revision 2.48 retrieving revision 2.49 diff -C2 -r2.48 -r2.49 *** PySystemState.java 2001/02/22 11:02:55 2.48 --- PySystemState.java 2001/02/22 11:10:38 2.49 *************** *** 75,78 **** --- 75,80 ---- public PyObject executable = Py.None; + public static PyList warnoptions; + private static PyJavaClass __builtin__class; *************** *** 375,378 **** --- 377,382 ---- __builtin__class = PyJavaClass.lookup(__builtin__.class); + + warnoptions = new PyList(); // Setup standard wrappers for stdout and stderr... Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -r2.38 -r2.39 *** Py.java 2001/02/22 11:06:51 2.38 --- Py.java 2001/02/22 11:10:38 2.39 *************** *** 216,219 **** --- 216,258 ---- public static PyObject Exception; + public static PyObject Warning; + public static void Warning(String message) { + warning(Warning, message); + } + + public static PyObject UserWarning; + public static void UserWarning(String message) { + warning(UserWarning, message); + } + + public static PyObject DeprecationWarning; + public static void DeprecationWarning(String message) { + warning(DeprecationWarning, message); + } + + public static PyObject SyntaxWarning; + public static void SyntaxWarning(String message) { + warning(SyntaxWarning, message); + } + + public static PyObject RuntimeWarning; + public static void RuntimeWarning(String message) { + warning(RuntimeWarning, message); + } + + public static void warning(PyObject category, String message) { + PyObject func = null; + PyObject mod = __builtin__.__import__("warnings"); + if (mod != null) + func = mod.__getattr__("warn"); + if (func == null) { + System.err.println("warning: " + message); + return; + } else { + func.__call__(Py.newString(message), category); + } + } + + public static PyObject JavaError; public static PyException JavaError(Throwable t) { *************** *** 432,435 **** --- 471,479 ---- SystemError = initExc("SystemError", exc, dict); MemoryError = initExc("MemoryError", exc, dict); + Warning = initExc("Warning", exc, dict); + UserWarning = initExc("UserWarning", exc, dict); + DeprecationWarning = initExc("DeprecationWarning", exc, dict); + SyntaxWarning = initExc("SyntaxWarning", exc, dict); + RuntimeWarning = initExc("RuntimeWarning", exc, dict); } |