Message11896
Failure in more detail:
singlejavatest:
[junit] Testsuite: org.python.core.PySystemStateTest
[junit] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.313 sec
[junit]
[junit] Testcase: testGetJarFileNameFromURL(org.python.core.PySystemStateTest): FAILED
[junit] expected:<[/]some_dir/some.jar> but was:<[]some_dir/some.jar>
[junit] junit.framework.ComparisonFailure: expected:<[/]some_dir/some.jar> but was:<[]some_dir/some.jar>
[junit] at org.python.core.PySystemStateTest.testGetJarFileNameFromURL(PySystemStateTest.java:21)
There isn't a drive letter involved here, but I appreciate the existence of drive letters invalidates otherwise correct manipulation in a lot of contexts. I've done some of that myself in the code base. (I never made getcwd() work correctly on the D-drive.)
Ideally we would depend on the nice people at Oracle/OpenJDK to get this stuff right. I'd love to re-work all this guff using java.nio.Paths one day. For now, I think java.io.File.toURI is probably the right answer.
>>> from java.io import File
>>> from java.util.jar import JarFile
>>> from java.net import URL
>>> f = File(r"dist\lib\test\blob.jar")
>>> f.getAbsoluteFile()
C:\Users\Jeff\Documents\Eclipse\jython-trunk\dist\lib\test\blob.jar
>>> f.toURI()
file:/C:/Users/Jeff/Documents/Eclipse/jython-trunk/dist/lib/test/blob.jar
>>> j = JarFile(r"dist\lib\test\blob.jar")
>>> list(j.entries())
[Blob.class, Blob.java]
>>> u = URL("jar:" + str(f.toURI()) + "!/Blob.java")
>>> u
jar:file:/C:/Users/Jeff/Documents/Eclipse/jython-trunk/dist/lib/test/blob.jar!/Blob.java
>>> import os
>>> os.path.relpath(u.getPath().split(':',1)[1].split('!')[0][1:])
u'dist\\lib\\test\\blob.jar'
To be honest, I've lightly lost the thread of #2386, and why we ended up with this test failure.:/ Does something in the round-trip I just made suggest a simple, cross-platform and correct version of getJarFileNameFromURL or getJarFileName ? |
|
Date |
User |
Action |
Args |
2018-04-12 20:22:10 | jeff.allen | set | messageid: <1523564530.92.0.682650639539.issue2410@psf.upfronthosting.co.za> |
2018-04-12 20:22:10 | jeff.allen | set | recipients:
+ jeff.allen, stefan.richthofer |
2018-04-12 20:22:10 | jeff.allen | link | issue2410 messages |
2018-04-12 20:22:09 | jeff.allen | create | |
|