Message11896

Author jeff.allen
Recipients jeff.allen, stefan.richthofer
Date 2018-04-12.20:22:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1523564530.92.0.682650639539.issue2410@psf.upfronthosting.co.za>
In-reply-to
Content
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 ?
History
Date User Action Args
2018-04-12 20:22:10jeff.allensetmessageid: <1523564530.92.0.682650639539.issue2410@psf.upfronthosting.co.za>
2018-04-12 20:22:10jeff.allensetrecipients: + jeff.allen, stefan.richthofer
2018-04-12 20:22:10jeff.allenlinkissue2410 messages
2018-04-12 20:22:09jeff.allencreate