[Jython-checkins] jython (2.5): Trial run switching private names to exactly match import.c for clarity.
frank.wierzbicki
jython-checkins at python.org
Mon Apr 23 22:52:29 CEST 2012
http://hg.python.org/jython/rev/0d492efbe788
changeset: 6612:0d492efbe788
branch: 2.5
parent: 6594:6dc91e602dea
user: Frank Wierzbicki <fwierzbicki at gmail.com>
date: Mon Apr 23 09:47:08 2012 -0700
summary:
Trial run switching private names to exactly match import.c for clarity.
files:
src/org/python/core/imp.java | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/org/python/core/imp.java b/src/org/python/core/imp.java
--- a/src/org/python/core/imp.java
+++ b/src/org/python/core/imp.java
@@ -659,13 +659,13 @@
if (tmp == null) {
return null;
}
- String name = tmp.toString();
+ String modname = tmp.toString();
// locate the current package
tmp = dict.__finditem__("__path__");
if (! (tmp instanceof PyList)) {
// __name__ is not a package name, try one level upwards.
- int dot = name.lastIndexOf('.');
+ int dot = modname.lastIndexOf('.');
if (dot == -1) {
if (level <= -1) {
// there is no package, perform an absolute search
@@ -673,19 +673,19 @@
}
throw Py.ValueError("Attempted relative import in non-package");
}
- // name should be the package name.
- name = name.substring(0, dot);
+ // modname should be the package name.
+ modname = modname.substring(0, dot);
}
// walk upwards if required (level >= 2)
while (level-- > 1) {
- int dot = name.lastIndexOf('.');
+ int dot = modname.lastIndexOf('.');
if (dot == -1) {
throw Py.ValueError("Attempted relative import beyond toplevel package");
}
- name = name.substring(0, dot);
+ modname = modname.substring(0, dot);
}
- return name.intern();
+ return modname.intern();
}
/**
@@ -791,14 +791,12 @@
}
/**
- * Most similar to import.c:import_module_ex.
- *
* @param name
* @param top
* @param modDict
* @return a module
*/
- private static PyObject import_name(String name, boolean top,
+ private static PyObject import_module_level(String name, boolean top,
PyObject modDict, PyObject fromlist, int level) {
if (name.length() == 0 && level <= 0) {
throw Py.ValueError("Empty module name");
@@ -890,7 +888,7 @@
* @return an imported module (Java or Python)
*/
public static PyObject importName(String name, boolean top) {
- return import_name(name, top, null, null, DEFAULT_LEVEL);
+ return import_module_level(name, top, null, null, DEFAULT_LEVEL);
}
/**
@@ -906,7 +904,7 @@
PyObject modDict, PyObject fromlist, int level) {
importLock.lock();
try {
- return import_name(name, top, modDict, fromlist, level);
+ return import_module_level(name, top, modDict, fromlist, level);
} finally {
importLock.unlock();
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list