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 2012年09月27日 18:41 by larry, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| larry.unittest.argv0.1.diff | larry, 2012年09月28日 09:20 | Patch to fix argv[0] executable for unittest. | review | |
| arnav.unittest.argv0.1.diff | Arnav.Khare, 2012年09月28日 14:05 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg171387 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年09月27日 18:41 | |
I wrote the following script called "bonkers.py": -- import sys print(sys.argv[0]) -- then ran % python3 -m unittest bonkers It printed -- ['python -m unittest', 'bonkers'] -- Shouldn't it say "python3", not "python"? Maybe it should use sys.executable? (Though that gets tricky if there are spaces in the filename.) |
|||
| msg171420 - (view) | Author: Chris Jerdonek (chris.jerdonek) * (Python committer) | Date: 2012年09月28日 09:09 | |
It looks like the offending line is here: http://hg.python.org/cpython/file/6ccb04c4cbae/Lib/unittest/__main__.py#l5 if sys.argv[0].endswith("__main__.py"): sys.argv[0] = "python -m unittest" |
|||
| msg171421 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年09月28日 09:20 | |
Certainly. But what is the right thing to do? I talked to Michael about it in person this morning, and our consensus was: use basename of sys.executable. Patch attached. |
|||
| msg171441 - (view) | Author: Chris Jerdonek (chris.jerdonek) * (Python committer) | Date: 2012年09月28日 11:43 | |
(I was just including the line for the convenience of anyone that might happen to come across the issue. It was not to inform you of course! :) ) FWIW, if you already know from talking to Michael or looking at the code, I think a comment saying why sys.argv[0] is being rewritten in the first place would be useful. For example, is it strictly to have a nicer-looking usage string for --help, or are there other reasons? $ ./python.exe -m unittest --help Usage: python -m unittest [options] ... |
|||
| msg171442 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2012年09月28日 11:45 | |
Yes it is for nicer help output, and a comment in the code is certainly warranted. |
|||
| msg171454 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年09月28日 13:13 | |
Michael, you're the one who came up with the feature. If you write the comment I'll fold it into the patch. |
|||
| msg171470 - (view) | Author: Arnav Khare (Arnav.Khare) | Date: 2012年09月28日 14:05 | |
Added comment explaining why we alter the executable string. |
|||
| msg171471 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年09月28日 14:14 | |
New changeset c76f1d78ff78 by Michael Foord in branch 'default': Closes issue 16064. No longer hard code executable name in unittest help output. http://hg.python.org/cpython/rev/c76f1d78ff78 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:36 | admin | set | github: 60268 |
| 2012年09月28日 14:14:51 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg171471 resolution: fixed stage: patch review -> resolved |
| 2012年09月28日 14:05:26 | Arnav.Khare | set | files:
+ arnav.unittest.argv0.1.diff nosy: + Arnav.Khare messages: + msg171470 |
| 2012年09月28日 13:13:22 | larry | set | messages: + msg171454 |
| 2012年09月28日 11:45:36 | michael.foord | set | messages: + msg171442 |
| 2012年09月28日 11:43:16 | chris.jerdonek | set | messages: + msg171441 |
| 2012年09月28日 09:20:07 | larry | set | files:
+ larry.unittest.argv0.1.diff keywords: + patch messages: + msg171421 stage: needs patch -> patch review |
| 2012年09月28日 09:09:11 | chris.jerdonek | set | nosy:
+ chris.jerdonek messages: + msg171420 |
| 2012年09月27日 18:41:19 | larry | create | |