[Jython-checkins] jython: Fix SyspathJavaLoader.getResources for empty resource String
darjus.loktevic
jython-checkins at python.org
Fri Oct 2 14:59:32 CEST 2015
https://hg.python.org/jython/rev/1d2db374fff9
changeset: 7739:1d2db374fff9
user: darjus at 60f81db49d06.ant.amazon.com
date: Fri Oct 02 22:55:38 2015 +1000
summary:
Fix SyspathJavaLoader.getResources for empty resource String
files:
src/org/python/core/SyspathJavaLoader.java | 20 +++++----
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/org/python/core/SyspathJavaLoader.java b/src/org/python/core/SyspathJavaLoader.java
--- a/src/org/python/core/SyspathJavaLoader.java
+++ b/src/org/python/core/SyspathJavaLoader.java
@@ -134,11 +134,9 @@
@Override
protected URL findResource(String res) {
PySystemState sys = Py.getSystemState();
-
- if (res.charAt(0) == SLASH_CHAR) {
- res = res.substring(1);
- }
- String entryRes = res;
+
+ res = deslashResource(res);
+ String entryRes = res;
if (File.separatorChar != SLASH_CHAR) {
res = res.replace(SLASH_CHAR, File.separatorChar);
entryRes = entryRes.replace(File.separatorChar, SLASH_CHAR);
@@ -183,10 +181,8 @@
List<URL> resources = new ArrayList<URL>();
PySystemState sys = Py.getSystemState();
-
- if (res.charAt(0) == SLASH_CHAR) {
- res = res.substring(1);
- }
+
+ res = deslashResource(res);
String entryRes = res;
if (File.separatorChar != SLASH_CHAR) {
res = res.replace(SLASH_CHAR, File.separatorChar);
@@ -258,5 +254,11 @@
return new RelativeFile(dir, accum + ".class");
}
+ private static String deslashResource(String res) {
+ if (!res.isEmpty() && res.charAt(0) == SLASH_CHAR) {
+ res = res.substring(1);
+ }
+ return res;
+ }
}
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list