From: <fwi...@us...> - 2008-10-13 17:19:51
|
Revision: 5384 http://jython.svn.sourceforge.net/jython/?rev=5384&view=rev Author: fwierzbicki Date: 2008-10-13 17:19:47 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Fixed issue http://bugs.jython.org/issue1111: keyword arguments not supported on __import__ Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/__builtin__.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2008-10-12 23:00:34 UTC (rev 5383) +++ trunk/jython/NEWS 2008-10-13 17:19:47 UTC (rev 5384) @@ -1,6 +1,9 @@ Jython NEWS Jython 2.5 + Bugs fixed (new numbering due to move to Roundup) + - [ 1111 ] keyword arguments not supported on __import__ + Incompatible Changes - The python.prepath property has been removed; use python.path instead. - To implement the Java Map interface, PyDictionary.values now returns a Modified: trunk/jython/src/org/python/core/__builtin__.java =================================================================== --- trunk/jython/src/org/python/core/__builtin__.java 2008-10-12 23:00:34 UTC (rev 5383) +++ trunk/jython/src/org/python/core/__builtin__.java 2008-10-13 17:19:47 UTC (rev 5384) @@ -1268,24 +1268,14 @@ "is the number of parent directories to search relative to the current module."); } -// public ImportFunction() { -// } - public PyObject __call__(PyObject args[], String keywords[]) { - if (!(args.length < 1 || args[0] instanceof PyString)) { - throw Py.TypeError("first argument must be a string"); - } - if (keywords.length > 0) { - throw Py.TypeError("__import__() takes no keyword arguments"); - } + ArgParser ap = new ArgParser("__import__", args, keywords, new String[]{"name", "globals", "locals", "fromlist", "level"}, 1); - int argc = args.length; - String module = args[0].__str__().toString(); + String module = ap.getString(0); + PyObject globals = ap.getPyObject(1, null); + PyObject fromlist = ap.getPyObject(3, Py.EmptyTuple); + int level = ap.getInt(4, imp.DEFAULT_LEVEL); - PyObject globals = (argc > 1 && args[1] != null) ? args[1] : null; - PyObject fromlist = (argc > 3 && args[3] != null) ? args[3] : Py.EmptyTuple; - int level = (argc > 4 && args[4] != null) ? Py.py2int(args[4]) : imp.DEFAULT_LEVEL; - return load(module, globals, fromlist, level); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |