Commits

Anonymous committed 3a2007c Merge

merge w/2.5: Fixing a UriSyntaxException on Windows

  • Participants
  • Parent commits 4b94fb5, e160ef3

Comments (0)

Files changed (3)

File 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

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

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