Update of /cvsroot/jython/jython/org/python/core
In directory usw-pr-cvs1:/tmp/cvs-serv10274
Modified Files:
exceptions.java
Log Message:
Fixed several bugs in SyntaxError.
- The class init was never run.
- Typo in text attribute.
- __str__ was defined wrongly and didn't return a CPython compatible
value.
Index: exceptions.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/exceptions.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** exceptions.java 2001/03/04 18:09:29 1.7
--- exceptions.java 2001/03/09 15:33:30 1.8
***************
*** 110,114 ****
"Base class for all standard Python exceptions.");
! buildClass(dict, "SyntaxError", "StandardError", "empty__init__",
"Invalid syntax");
--- 110,114 ----
"Base class for all standard Python exceptions.");
! buildClass(dict, "SyntaxError", "StandardError", "SyntaxError",
"Invalid syntax");
***************
*** 297,309 ****
self.__setattr__("lineno", tmp[1]);
self.__setattr__("offset", tmp[2]);
! self.__setattr__("texe", tmp[3]);
} catch (PyException exc) { ; }
}
}
! public static PyString SyntaxError__str__(PyObject self) {
! return self.__getattr__("msg").__str__();
}
-
public static PyObject EnvironmentError(PyObject[] arg, String[] kws) {
--- 297,329 ----
self.__setattr__("lineno", tmp[1]);
self.__setattr__("offset", tmp[2]);
! self.__setattr__("text", tmp[3]);
} catch (PyException exc) { ; }
}
}
! public static PyString SyntaxError__str__(PyObject[] arg, String[] kws) {
! ArgParser ap = new ArgParser("__init__", arg, kws, "self", "args");
! PyObject self = ap.getPyObject(0);
! PyString str = self.__getattr__("msg").__str__();
! PyObject filename = basename(self.__findattr__("filename"));
! PyObject lineno = self.__findattr__("lineno");
! if (filename instanceof PyString && lineno instanceof PyInteger)
! return new PyString(str + " (" + filename + ", line " + lineno + ")");
! else if (filename instanceof PyString)
! return new PyString(str + " (" + filename + ")");
! else if (lineno instanceof PyInteger)
! return new PyString(str + " (line " + lineno + ")");
! return str;
! }
!
! private static PyObject basename(PyObject filename) {
! if (filename instanceof PyString) {
! int i = ((PyString) filename).rfind(java.io.File.separator);
! if (i >= 0)
! return filename.__getslice__(
! new PyInteger(i+1), new PyInteger(Integer.MAX_VALUE));
! }
! return filename;
}
public static PyObject EnvironmentError(PyObject[] arg, String[] kws) {
|