[Jython-checkins] jython (merge 2.5 -> default): merge w/2.5: Fixing a UriSyntaxException on Windows
alan.kennedy
jython-checkins at python.org
Sat Oct 27 16:11:38 CEST 2012
http://hg.python.org/jython/rev/3a2007cde9f4
changeset: 6876:3a2007cde9f4
parent: 6874:4b94fb54b573
parent: 6875:e160ef3d208f
user: Alan Kennedy <alan at xhaus.com>
date: Sat Oct 27 15:07:56 2012 +0100
summary:
merge w/2.5: Fixing a UriSyntaxException on Windows
files:
Lib/test/test_sys_jy.py | 6 ++++++
src/org/python/core/SyspathArchive.java | 8 ++++++++
src/org/python/core/SyspathJavaLoader.java | 2 +-
3 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_sys_jy.py b/Lib/test/test_sys_jy.py
--- a/Lib/test/test_sys_jy.py
+++ b/Lib/test/test_sys_jy.py
@@ -148,6 +148,12 @@
from pck import Main
self.assert_(Main.getResource('Main.txt'))
+ def test_url_from_resource_from_syspath(self):
+ from pck import Main
+ # Need to test this doesn't fail because of '\' chars in the path
+ # Really only a problem on Windows
+ self.assert_(Main.getResource('Main.txt').toURI())
+
class SyspathUnicodeTest(unittest.TestCase):
"""bug 1693: importing from a unicode path threw a unicode encoding
diff --git a/src/org/python/core/SyspathArchive.java b/src/org/python/core/SyspathArchive.java
--- a/src/org/python/core/SyspathArchive.java
+++ b/src/org/python/core/SyspathArchive.java
@@ -61,6 +61,14 @@
return this.zipFile.getEntry(makeEntry(entryName));
}
+ public String asUriCompatibleString() {
+ String result = __str__().toString();
+ if (File.separatorChar == '\\') {
+ return result.replace(File.separatorChar, '/');
+ }
+ return result;
+ }
+
InputStream getInputStream(ZipEntry entry) throws IOException {
InputStream istream = this.zipFile.getInputStream(entry);
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
@@ -148,7 +148,7 @@
ZipEntry ze = archive.getEntry(entryRes);
if (ze != null) {
try {
- return new URL("jar:file:" + entry.__str__().toString() + "!/" + entryRes);
+ return new URL("jar:file:" + archive.asUriCompatibleString() + "!/" + entryRes);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list