-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IllegalArgumentException after using dir(jpype.JPackage("mypackage"))
and non-ascii paths.
#1194
Comments
To debug the problem the first step is to get a full stacktrace.
This will yield....
So the last place before it goes into Java library land is The next step would be to build a custom version of the org.jpype.jar with appropriate instrumentation to see what is the issue. There are two possibilities.
Let start by looking upstream to see if we can find the corresponding context of the call. Thus we need to see about finding the entry point. Grepping we find "getContext" to be created at
As we can see here there is absolutely no string handling taking place. The input and output are not strings so no encoding conversion is expected. (This is most unfortunate as that means the issue is with Java and not JPype directly.) The other relevant point is getting the Package name through to Java.
Again this points to a downstream library problem in Java. So next we instrument the jar file with ....
We then recompile with Now the next part is going to get a bit tricky because if we just place the org.jpype.jar in the working directory and run it likely it will get ignored if the bad path is the issue. So we may need to copy it the installed JPype copy and try it there. But lets give the simple try first and hope it works...
We make a quick modification to play org.jpype.jar on the classpath so we can use our modified copy. For the good example we get...
For the bad example we get
So here is the issue the getContents while looking up the path is failing to properly encode the uri. Thus the problem must be in getContents which is calling getPath. Tracking down from that point the problem is then shown to first appear at The code reads...
So basically we are just calling At this point we would need to find a patch to address the flaw in Java. Unfortunately, this is the extent of my time available right now. Hopefully I can get a deeper look later. My first attempt would be to just blattently replace Hopefully this is helpful in working out a solution. |
BTW thanks for the detailed bug report. Though I don't have an immediate solution, I was able to use the report to quickly get the isolating the source of the issue which will hopefully make a fix possible. |
@Thrameos thank you this hugely helpful. I'll let you know if I figure anything more out. |
It appears that
dir(jpype.JPackage("mypackage"))
does not handle non-ASCII characters anywhere in its package path. This method is critical for tools like stubgenj that loop over packages usingdir
.Consider the following working and broken cases:
Both are identical, except for the name of the working directory. The
good_example.py
andbad_example.py
scripts are:The output of
bad_workdir_à/bad_example.py
is:The output of
good_workdir/good_example.py
is:I would expect the output of
bad_workdir_à/bad_example.py
to be the same asgood_workdir/good_example.py
. I've attached the files I used to reproduce this bug.jpype_bug.zip
The text was updated successfully, but these errors were encountered: