Index: src/org/python/core/imp.java =================================================================== --- src/org/python/core/imp.java (revision 5670) +++ src/org/python/core/imp.java Mon Dec 01 14:10:51 EST 2008 @@ -173,6 +173,11 @@ Py.writeDebug(IMPORT_LOG, "Unable to write to source cache file '" + compiledFilename + "' due to " + exc); return null; + } catch(SecurityException exc) { + // If we can't write the cache file, just log and continue + Py.writeDebug(IMPORT_LOG, "Unable to write to source cache file '" + + compiledFilename + "' due to " + exc); + return null; } finally { if(fop != null) { try { @@ -440,8 +445,11 @@ File sourceFile = new File(dir, sourceName); File compiledFile = new File(dir, compiledName); - boolean pkg = dir.isDirectory() && caseok(dir, name) && (sourceFile.isFile() + boolean pkg = false; + try { + pkg = dir.isDirectory() && caseok(dir, name) && (sourceFile.isFile() || compiledFile.isFile()); + } catch (SecurityException e) {} if (!pkg) { Py.writeDebug(IMPORT_LOG, "trying source " + dir.getPath()); sourceName = name + ".py"; @@ -456,29 +464,31 @@ m.__dict__.__setitem__("__path__", new PyList(new PyObject[] {filename})); } + try { - if (sourceFile.isFile() && caseok(sourceFile, sourceName)) { - if (compiledFile.isFile() && caseok(compiledFile, compiledName)) { - Py.writeDebug(IMPORT_LOG, "trying precompiled " + compiledFile.getPath()); - long pyTime = sourceFile.lastModified(); - long classTime = compiledFile.lastModified(); - if (classTime >= pyTime) { - PyObject ret = createFromPyClass(modName, makeStream(compiledFile), true, - displaySourceName, displayCompiledName); - if (ret != null) { - return ret; - } - } - } - return createFromSource(modName, makeStream(sourceFile), displaySourceName, - compiledFile.getPath()); - } + if (sourceFile.isFile() && caseok(sourceFile, sourceName)) { + if (compiledFile.isFile() && caseok(compiledFile, compiledName)) { + Py.writeDebug(IMPORT_LOG, "trying precompiled " + compiledFile.getPath()); + long pyTime = sourceFile.lastModified(); + long classTime = compiledFile.lastModified(); + if (classTime >= pyTime) { + PyObject ret = createFromPyClass(modName, makeStream(compiledFile), true, + displaySourceName, displayCompiledName); + if (ret != null) { + return ret; + } + } + } + return createFromSource(modName, makeStream(sourceFile), displaySourceName, + compiledFile.getPath()); + } - // If no source, try loading precompiled - Py.writeDebug(IMPORT_LOG, "trying precompiled with no source " + compiledFile.getPath()); - if (compiledFile.isFile() && caseok(compiledFile, compiledName)) { - return createFromPyClass(modName, makeStream(compiledFile), true, displaySourceName, - displayCompiledName); - } + // If no source, try loading precompiled + Py.writeDebug(IMPORT_LOG, "trying precompiled with no source " + compiledFile.getPath()); + if (compiledFile.isFile() && caseok(compiledFile, compiledName)) { + return createFromPyClass(modName, makeStream(compiledFile), true, displaySourceName, + displayCompiledName); + } + } catch (SecurityException e) {} return null; } Index: src/org/python/core/PyTraceback.java =================================================================== --- src/org/python/core/PyTraceback.java (revision 5670) +++ src/org/python/core/PyTraceback.java Fri Nov 28 18:28:52 EST 2008 @@ -51,10 +51,14 @@ */ private String getLine(String filename, int lineno) { RelativeFile file = new RelativeFile(filename); + try { - if (!file.isFile() || !file.canRead()) { - // XXX: We should run through sys.path until the filename is found - return null; - } + if (!file.isFile() || !file.canRead()) { + // XXX: We should run through sys.path until the filename is found + return null; + } + } catch (SecurityException e) { + return null; // If we don't have read access to the file, return null + } PyFile pyFile; try { Index: src/org/python/core/packagecache/PathPackageManager.java =================================================================== --- src/org/python/core/packagecache/PathPackageManager.java (revision 5670) +++ src/org/python/core/packagecache/PathPackageManager.java Mon Dec 01 14:10:51 EST 2008 @@ -41,21 +41,23 @@ String dir = path.pyget(i).__str__().toString(); File f = new RelativeFile(dir, child); + try { - if (f.isDirectory() && imp.caseok(f, name)) { - /* - * Figure out if we have a directory a mixture of python and - * java or just an empty directory (which means Java) or a - * directory with only Python source (which means Python). - */ - PackageExistsFileFilter m = new PackageExistsFileFilter(); - f.listFiles(m); - boolean exists = m.packageExists(); - if (exists) { - Py.writeComment("import", "java package as '" - + f.getAbsolutePath() + "'"); - } - return exists; - } + if (f.isDirectory() && imp.caseok(f, name)) { + /* + * Figure out if we have a directory a mixture of python and + * java or just an empty directory (which means Java) or a + * directory with only Python source (which means Python). + */ + PackageExistsFileFilter m = new PackageExistsFileFilter(); + f.listFiles(m); + boolean exists = m.packageExists(); + if (exists) { + Py.writeComment("import", "java package as '" + + f.getAbsolutePath() + "'"); + } + return exists; + } + } catch (SecurityException se) {} } return false; } Index: src/org/python/modules/zipimport/zipimporter.java =================================================================== --- src/org/python/modules/zipimport/zipimporter.java (revision 5670) +++ src/org/python/modules/zipimport/zipimporter.java Mon Dec 01 14:13:28 EST 2008 @@ -115,10 +115,14 @@ prefix = ""; while (true) { File fullPathFile = new File(sys.getPath(pathFile.getPath())); + try { - if (fullPathFile.isFile()) { - archive = pathFile.getPath(); - break; - } + if (fullPathFile.isFile()) { + archive = pathFile.getPath(); + break; + } + } catch (SecurityException se) { + throw zipimport.ZipImportError("file not accessible"); + } // back up one path element File parentFile = pathFile.getParentFile(); @@ -582,8 +586,8 @@ * Convert the date/time values found in the Zip archive to a long * time (in milliseconds) value. * - * @param dostime a dos style timestamp (only time) integer - * @param dosdate a dos style date integer + * @param dosTime a dos style timestamp (only time) integer + * @param dosDate a dos style date integer * @return a long time (in milliseconds) value */ private long dosTimeToEpoch(int dosTime, int dosDate) { Index: src/org/python/core/SyspathJavaLoader.java =================================================================== --- src/org/python/core/SyspathJavaLoader.java (revision 5670) +++ src/org/python/core/SyspathJavaLoader.java Mon Dec 01 14:10:52 EST 2008 @@ -96,6 +96,7 @@ try { return Class.forName(name, true, ClassLoader.getSystemClassLoader()); } catch(ClassNotFoundException e) {} + catch (SecurityException se) {} Class c = findLoadedClass(name); if(c != null) { @@ -124,14 +125,14 @@ String dir = entry.__str__().toString(); file = getFile(dir, name); if(file != null) { - size = (int)file.length(); try { + size = (int)file.length(); fis = new FileInputStream(file); } catch(FileNotFoundException e) { ; + } catch(SecurityException e) {} - } - } + } + } - } if(fis == null) { continue; }