Update of /cvsroot/jython/jython/org/python/core
In directory usw-pr-cvs1:/tmp/cvs-serv30401
Modified Files:
imp.java
Log Message:
caseok(): Fix a bug where a foo.PY file could not be imported.
Index: imp.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v
retrieving revision 2.48
retrieving revision 2.49
diff -C2 -d -r2.48 -r2.49
*** imp.java 2001/07/17 20:34:35 2.48
--- imp.java 2001/07/23 19:30:44 2.49
***************
*** 274,277 ****
--- 274,278 ----
if (o != null) return o;
+ int nlen = name.length();
String pyName = name+".py";
String className = name+"$py.class";
***************
*** 299,303 ****
// First check for packages
File dir = new File(dirName, name);
! if (dir.isDirectory() && caseok(dir, name) &&
(new File(dir, "__init__.py").isFile() ||
new File(dir, "__init__$py.class").isFile()))
--- 300,304 ----
// First check for packages
File dir = new File(dirName, name);
! if (dir.isDirectory() && caseok(dir, name, nlen) &&
(new File(dir, "__init__.py").isFile() ||
new File(dir, "__init__$py.class").isFile()))
***************
*** 318,323 ****
Py.writeDebug("import", "trying source " + pyFile.getPath());
! if (pyFile.isFile() && caseok(pyFile, pyName)) {
! if (classFile.isFile() && caseok(classFile, className)) {
Py.writeDebug("import", "trying precompiled " +
classFile.getPath());
--- 319,324 ----
Py.writeDebug("import", "trying source " + pyFile.getPath());
! if (pyFile.isFile() && caseok(pyFile, pyName, nlen)) {
! if (classFile.isFile() && caseok(classFile, className, nlen)) {
Py.writeDebug("import", "trying precompiled " +
classFile.getPath());
***************
*** 338,342 ****
// If no source, try loading precompiled
Py.writeDebug("import", "trying " + classFile.getPath());
! if (classFile.isFile() && caseok(classFile, className)) {
return createFromPyClass(modName, makeStream(classFile),
false, classFile.getPath());
--- 339,343 ----
// If no source, try loading precompiled
Py.writeDebug("import", "trying " + classFile.getPath());
! if (classFile.isFile() && caseok(classFile, className, nlen)) {
return createFromPyClass(modName, makeStream(classFile),
false, classFile.getPath());
***************
*** 346,355 ****
}
! private static boolean caseok(File file, String filename) {
if (Options.caseok)
return true;
try {
File canFile = new File(file.getCanonicalPath());
! return filename.equals(canFile.getName());
} catch (IOException exc) {
return false;
--- 347,356 ----
}
! private static boolean caseok(File file, String filename, int namelen) {
if (Options.caseok)
return true;
try {
File canFile = new File(file.getCanonicalPath());
! return filename.regionMatches(0, canFile.getName(), 0, namelen);
} catch (IOException exc) {
return false;
|