Title: Windows arg parsing, double space in literal string is escape sequence
Type: behaviour Severity: normal
Components: None Versions: Jython 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: bcorliss, fwierzbicki, saltnlight5, zyasoft
Priority: normal Keywords:

Created on 2010-12-13.22:34:17 by bcorliss, last changed 2015-03-10.18:35:24 by zyasoft.

msg6277 (view) Author: Bruce Corliss (bcorliss) Date: 2010-12-13.22:34:17
First off, I just want to say that I think Jython is awesome and I appreciate all of the work that has been put into it!!   :)

When passing an argument to jython that includes path encased in double quotes, jython will fail to preserve that raw path string:

This call works, and the image is opened:
jython.bat -r 10 -c 10 -x 17 -y 17 "C:/Documents and Settings/.../A B/TP_0/lm_tile/tile_rgb_z1.png"

If a double spaced is added in between "A B" then the image cannot be found.  The python script has been tested and supports raw strings for paths.
 jython.bat -r 10 -c 10 -x 17 -y 17 "C:/Documents and Settings/.../A  B/TP_0/lm_tile/tile_rgb_z1.png"
javax.imageio.IIOException: javax.imageio.IIOException: Can't read input file! 
Exception while removing reference: java.util.concurrent.RejectedExecutionException 
	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(Unknown Source) 
	at java.util.concurrent.ThreadPoolExecutor.reject(Unknown Source) 
	at java.util.concurrent.ThreadPoolExecutor.execute(Unknown Source) 
	at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) 
	at$ComInvoker.invoke(Unknown Source) 
	at$FolderDisposer.dispose(Unknown Source) 
	at Source) 
	at Source) 

As an aside, I am wondering why the argument parsing is handled in the .bat file and not in a java script that calls jython.  Having the argument parsing handled in one place instead of operating system specific scripts might be easier.  Is there any benefit to having the parsing done is the arcane language of the .bat file?

Thank you for your time.

Best Regards,
msg6278 (view) Author: Bruce Corliss (bcorliss) Date: 2010-12-13.22:35:57
Forgot to say:

Using Windows XP Professional SP 3.
Call from windows command line.
msg6279 (view) Author: Zemian Deng (saltnlight5) Date: 2010-12-14.05:32:23
I can confirm this on my XP cmd.exe prompt too. I agree wrapper script should do the minimal as possible.

As for now, your quickest workaround maybe just to write a simple wrapper .bat of you own. It can be as simple as this and place it under jython\bin\jython2.bat dir.

@echo off
set scriptdir=%~dp0%
java -cp "%scriptdir%..\*;%scriptdir%..\javalib\*" org.python.util.jython %*

I hope this helps.
msg9610 (view) Author: Jim Baker (zyasoft) Date: 2015-03-10.18:35:24
Fixed as of
Date User Action Args
2015-03-10 18:35:24zyasoftsetstatus: open -> closed
resolution: fixed
messages: + msg9610
nosy: + zyasoft
versions: + Jython 2.7, - Jython 2.5
2013-02-19 23:24:58fwierzbickisetpriority: normal
nosy: + fwierzbicki
versions: + Jython 2.5, - 2.5.2rc
2010-12-14 05:32:23saltnlight5setnosy: + saltnlight5
messages: + msg6279
2010-12-13 22:35:57bcorlisssetmessages: + msg6278
2010-12-13 22:34:17bcorlisscreate