From: <fwi...@us...> - 2008-10-15 17:07:58
|
Revision: 5399 http://jython.svn.sourceforge.net/jython/?rev=5399&view=rev Author: fwierzbicki Date: 2008-10-15 17:06:58 +0000 (Wed, 15 Oct 2008) Log Message: ----------- New dotted and absolute import support. I have local tests, but have not figured out how to integrate them into the regression tests. Examining the tests in CPython does not appear to give much guidance here, the testing of these features looks pretty thin (mainly they test features around __package__ which is new in 2.6). Maybe I just haven't found the relevant tests? Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-10-15 15:56:58 UTC (rev 5398) +++ trunk/jython/src/org/python/core/imp.java 2008-10-15 17:06:58 UTC (rev 5399) @@ -529,6 +529,9 @@ * @return the parent name for a module */ private static String getParent(PyObject dict, int level) { + if (dict == null || level == 0) { + return null; + } PyObject tmp = dict.__finditem__("__name__"); if (tmp == null) { return null; @@ -538,13 +541,23 @@ tmp = dict.__finditem__("__path__"); if (tmp != null && tmp instanceof PyList) { return name.intern(); - } else { - int dot = name.lastIndexOf('.'); + } + int dot = name.lastIndexOf('.'); + if (dot == -1) { + if (level > 0) { + throw Py.ValueError("Attempted relative import in non-package"); + } + return null; + } + name = name.substring(0, dot); + while (--level > 0) { + dot = name.lastIndexOf('.'); if (dot == -1) { - return null; + throw Py.ValueError("Attempted relative import beyond toplevel package"); } - return name.substring(0, dot).intern(); + name = name.substring(0, dot); } + return name.intern(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-10-31 17:43:57
|
Revision: 5540 http://jython.svn.sourceforge.net/jython/?rev=5540&view=rev Author: pjenvey Date: 2008-10-31 17:43:52 +0000 (Fri, 31 Oct 2008) Log Message: ----------- bump bytecode magic for all the compiler changes since alpha3 Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-10-31 17:23:18 UTC (rev 5539) +++ trunk/jython/src/org/python/core/imp.java 2008-10-31 17:43:52 UTC (rev 5540) @@ -22,7 +22,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - public static final int APIVersion = 15; + public static final int APIVersion = 16; //This should change to 0 for Python 2.7 and 3.0 see PEP 328 public static final int DEFAULT_LEVEL = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-14 17:53:30
|
Revision: 5580 http://jython.svn.sourceforge.net/jython/?rev=5580&view=rev Author: fwierzbicki Date: 2008-11-14 17:53:21 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Remove very old commented out code from imp.java. Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-11-14 16:07:43 UTC (rev 5579) +++ trunk/jython/src/org/python/core/imp.java 2008-11-14 17:53:21 UTC (rev 5580) @@ -755,10 +755,6 @@ public static PyObject importOne(String mod, PyFrame frame) { PyObject module = __builtin__.__import__(mod, frame.f_globals, frame .getLocals(), Py.EmptyTuple); - /* - * int dot = mod.indexOf('.'); if (dot != -1) { mod = mod.substring(0, - * dot).intern(); } - */ return module; } @@ -769,7 +765,6 @@ public static PyObject importOneAs(String mod, PyFrame frame) { PyObject module = __builtin__.__import__(mod, frame.f_globals, frame .getLocals(), getStarArg()); - // frame.setlocal(asname, module); return module; } @@ -924,9 +919,6 @@ name = name.substring(dot + 1, name.length()).intern(); } - // This should be better "protected" - // ((PyStringMap)nm.__dict__).clear(); - nm.__setattr__("__name__", new PyString(modName)); PyObject ret = find_module(name, modName, path); modules.__setitem__(modName, ret); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-03 16:43:34
|
Revision: 6155 http://jython.svn.sourceforge.net/jython/?rev=6155&view=rev Author: pjenvey Date: 2009-04-03 16:43:24 +0000 (Fri, 03 Apr 2009) Log Message: ----------- bump magic for r6135/6142 changes Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-04-03 06:06:39 UTC (rev 6154) +++ trunk/jython/src/org/python/core/imp.java 2009-04-03 16:43:24 UTC (rev 6155) @@ -20,7 +20,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - public static final int APIVersion = 18; + public static final int APIVersion = 19; public static final int NO_MTIME = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-31 18:46:13
|
Revision: 6735 http://jython.svn.sourceforge.net/jython/?rev=6735&view=rev Author: fwierzbicki Date: 2009-08-31 18:46:06 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Fix for http://bugs.jython.org/issue1424 "Relative imports do not work in some cases". Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-08-31 17:40:57 UTC (rev 6734) +++ trunk/jython/src/org/python/core/imp.java 2009-08-31 18:46:06 UTC (rev 6735) @@ -619,7 +619,7 @@ */ private static PyObject import_next(PyObject mod, StringBuilder parentNameBuffer, String name, String outerFullName, PyObject fromlist) { - if (parentNameBuffer.length() > 0) { + if (parentNameBuffer.length() > 0 && name != null && name.length() > 0) { parentNameBuffer.append('.'); } parentNameBuffer.append(name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-09-01 13:57:59
|
Revision: 6737 http://jython.svn.sourceforge.net/jython/?rev=6737&view=rev Author: fwierzbicki Date: 2009-09-01 13:57:52 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Increment APIVersion for coroutine bugfixes in compiler. Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-08-31 18:47:55 UTC (rev 6736) +++ trunk/jython/src/org/python/core/imp.java 2009-09-01 13:57:52 UTC (rev 6737) @@ -21,7 +21,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - private static final int APIVersion = 24; + private static final int APIVersion = 25; public static final int NO_MTIME = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-04-13 00:35:53
|
Revision: 7023 http://jython.svn.sourceforge.net/jython/?rev=7023&view=rev Author: pjenvey Date: 2010-04-13 00:35:47 +0000 (Tue, 13 Apr 2010) Log Message: ----------- bump bytecode magic Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2010-04-12 22:03:17 UTC (rev 7022) +++ trunk/jython/src/org/python/core/imp.java 2010-04-13 00:35:47 UTC (rev 7023) @@ -21,7 +21,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - private static final int APIVersion = 26; + private static final int APIVersion = 27; public static final int NO_MTIME = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-09-04 02:43:10
|
Revision: 7110 http://jython.svn.sourceforge.net/jython/?rev=7110&view=rev Author: zyasoft Date: 2010-09-04 02:43:03 +0000 (Sat, 04 Sep 2010) Log Message: ----------- Doc cleanup Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2010-08-28 03:52:43 UTC (rev 7109) +++ trunk/jython/src/org/python/core/imp.java 2010-09-04 02:43:03 UTC (rev 7110) @@ -48,22 +48,24 @@ } /** - * <p> - * Selects the parent class loader for Jython, used for dinamically load classes and resources + * Selects the parent class loader for Jython, to be used for + * dynamically loaded classes and resources. Chooses between the + * current and context classloader based on the following + * criteria: + * + * <ul> + * <li>If both are the same classloader, return that classloader. + * <li>If either is null, then the non-null one is selected. + * <li>If both are not null, and a parent/child relationship can + * be determined, then the child is selected. + * <li>If both are not null and not on a parent/child + * relationship, then the current class loader is returned (since + * it is likely for the context class loader to <b>not</b> see the + * Jython classes) + * </ul> * - * <p> - * The current implementation chooses between the current and context - * classloader based on the following criteria:<ul> - * - * <li>If both are the same, that one is returned. - * <li>If either is null, the non-null one is selected. - * <li>If both are not null, and a parent/child relationship can be determined, - * the child is selected. - * <li>If both are not null and not on a parent/child relationship, the - * current class loader is returned (since it is likely for the - * context class loader to <b>not</b> see the Jython classes) - * - * @return the parent class loader for Jython or null if both the current and context classloaders are null; + * @return the parent class loader for Jython or null if both the + * current and context classloaders are null. */ public static ClassLoader getParentClassLoader() { ClassLoader current = imp.class.getClassLoader(); @@ -252,14 +254,15 @@ /** * Stores the bytes in compiledSource in compiledFilename. * - * If compiledFilename is null it's set to the results of - * makeCompiledFilename(sourcefileName) + * If compiledFilename is null, it's set to the results of + * makeCompiledFilename(sourcefileName). * - * If sourceFilename is null or set to UNKNOWN_SOURCEFILE null is returned + * If sourceFilename is null or set to UNKNOWN_SOURCEFILE, then + * null is returned. * - * @return the compiledFilename eventually used or null if a - * compiledFilename couldn't be determined of if an error was thrown - * while writing to the cache file. + * @return the compiledFilename eventually used; or null if a + * compiledFilename couldn't be determined or if an error + * was thrown while writing to the cache file. */ public static String cacheCompiledSource(String sourceFilename, String compiledFilename, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |