This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年07月06日 10:54 by yoch.melka, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| test_argv_1.py | yoch.melka, 2011年07月06日 10:54 | test case | ||
| Messages (10) | |||
|---|---|---|---|
| msg139930 - (view) | Author: yoch (yoch.melka) | Date: 2011年07月06日 10:54 | |
Hi, I'm using sys.argv to retrieve files and process them on the command line. Wildcards arguments (like : test.py *.txt) works fine under Linux (expanded), but not on Windows. It also affects the fileinput functions. The solution is to change the compilation options msvc, as mentioned here: http://msdn.microsoft.com/en-us/library/8bch7bkk.aspx Regards, yoch |
|||
| msg139937 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2011年07月06日 14:31 | |
But what if you don't want the expansion done? I always invoke python from cygwin's bash shell, and sometimes I tell the shell not to expand the arguments, such as: python \* or python '*' I wouldn't want python (or rather the C runtime) to do the expansion in this case, and I don't see how it could know not to do it. |
|||
| msg139938 - (view) | Author: yoch (yoch.melka) | Date: 2011年07月06日 17:10 | |
Escape the wildcard like '*' will work (like on Linux). I think \* will not work... |
|||
| msg139941 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2011年07月06日 17:28 | |
Both of them work under cygwin. My point is that neither would work if the C runtime expanded command line arguments. |
|||
| msg139942 - (view) | Author: yoch (yoch.melka) | Date: 2011年07月06日 18:49 | |
'setargv.obj' not C runtime, it's only static library to allow expanding wildcards arguments received by the program. (MinGW uses approximately the same principle for executables compilation) And, it's not appropriate to tell people who need this feature (arguments expanding) to work only with cygwin ... |
|||
| msg139943 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2011年07月06日 18:58 | |
I'm not suggesting they use cygwin. I'm saying that if they do use cygwin that something they currently do would stop working. There would be no way to pass a command line parameter of "*" to python, at least without adding more escaping (hard to say, documentation of setargv.obj is sparse). Of course this would be true from any shell, I'm just familiar with the syntax of doing so under bash. While it might be a separate .obj file, I believe it's still part of the logical C runtime that gets invoked before python's main(). Or am I missing something? (entirely possible, it's been a while since I've used setargv.obj) |
|||
| msg139944 - (view) | Author: yoch (yoch.melka) | Date: 2011年07月06日 19:12 | |
With cmd and program compiled with setargv.obj, 'command *' is expanded, but not 'command "*"'. So, it's possible to escape them normally. [q] While it might be a separate .obj file, I believe it's still part of the logical C runtime that gets invoked before python's main(). Or am I missing something? (entirely possible, it's been a while since I've used setargv.obj) [/q] I dont't know. But what difference does it make, after all? ( I'm not sure I understand, my english is poor ;) ) |
|||
| msg139945 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2011年07月06日 19:19 | |
> I dont't know. But what difference does it make, after all? I just want to make sure it's something that happens automatically and wouldn't require a change to python's C code. To the other point, someone who currently uses: python '*' would need to change to: python '"*"' I'm just pointing out that it's a change for some users, and might break some existing usage of python. I can't say whether or not that's a big problem or not. |
|||
| msg139948 - (view) | Author: Sebastian Ramacher (sebastinas) | Date: 2011年07月06日 20:04 | |
That is definitely not python's job. That is the duty of your shell and python should never expand that. And it would lead to platform specific behavior as one can see with the following script: import sys import subprocess if __name__ == "__main__": if len(sys.argv) == 1: subprocess.Popen([sys.executable, __file__, "foo", "*"]) else: print sys.argv[1:] With setargv.obj the argument would be expanded on Windows whereas on any other platform it just prints [foo, *]. |
|||
| msg139949 - (view) | Author: yoch (yoch.melka) | Date: 2011年07月06日 20:28 | |
Okay. Thanks :) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56714 |
| 2011年07月06日 20:41:27 | brian.curtin | set | status: open -> closed type: behavior resolution: not a bug stage: resolved |
| 2011年07月06日 20:28:27 | yoch.melka | set | messages: + msg139949 |
| 2011年07月06日 20:04:06 | sebastinas | set | nosy:
+ sebastinas messages: + msg139948 |
| 2011年07月06日 19:19:27 | eric.smith | set | messages: + msg139945 |
| 2011年07月06日 19:12:30 | yoch.melka | set | messages: + msg139944 |
| 2011年07月06日 18:58:18 | eric.smith | set | messages: + msg139943 |
| 2011年07月06日 18:49:35 | yoch.melka | set | messages: + msg139942 |
| 2011年07月06日 17:28:19 | eric.smith | set | messages: + msg139941 |
| 2011年07月06日 17:10:18 | yoch.melka | set | messages: + msg139938 |
| 2011年07月06日 14:31:37 | eric.smith | set | nosy:
+ eric.smith messages: + msg139937 |
| 2011年07月06日 10:54:56 | yoch.melka | create | |