Anonymous avatar Anonymous committed 3a2007c Merge

merge w/2.5: Fixing a UriSyntaxException on Windows

Comments (0)

Files changed (3)

Lib/test/test_sys_jy.py

         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

src/org/python/core/SyspathArchive.java

         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);
 

src/org/python/core/SyspathJavaLoader.java

                 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);
 					}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.