--version weirdness
There's some weirdness that happens if you pass both --version and a subcommand, or another option, to manage.py (or django-admin.py):
kmt@lbox:~/software/web/playground$ ./manage.py --version --help
1.1 beta 1 SVN-11115
Unknown command: '--version'
Type 'manage.py help' for usage.
kmt@lbox:~/software/web/playground$ ./manage.py runserver --version
1.1 beta 1 SVN-11115
1.1 beta 1 SVN-11115
kmt@lbox:~/software/web/playground$ ./manage.py test --version
1.1 beta 1 SVN-11115
1.1 beta 1 SVN-11115
kmt@lbox:~/software/web/playground$ ./manage.py lskdjfljtest --version
1.1 beta 1 SVN-11115
Unknown command: 'lskdjfljtest'
Type 'manage.py help' for usage.
kmt@lbox:~/software/web/playground$
--version
as provided by optparse.OptionParser
is documented to print the version string and exit. This is done when parse_args
is called. However the LaxOptionParser
defined and used within django.core.management.__init__
overrides _process_args
so that the SystemExit raised when --version
is processed is swallowed/ignored. Thus the version gets printed but the program does not exit but rather proceeds. Things then may get a little confused depending on what else has been specified on the command line. In the case of no subcommand the --version argument is attempted to be interpreted as a subcommand. In the case of a valid subcommand being specified, a regular OptionParser
is called to process the arguments for it, and that one will again print the version string but then actually exit. In the case of an invalid subcommand, you'll get a message to that effect. This last one actually looks like reasonable behavior but the others are a bit confusing, so it would probably be better if the program did consistently exit on the first processing of --version
, ignoring whatever else may have been specified.
Change History
(12)
Triage Stage: |
Unreviewed → Accepted
|
Severity: |
→ Normal
|
Type: |
→ Bug
|
Easy pickings: |
unset
|
Owner: |
changed from nobody to Mark Barrett
|
Status: |
new → assigned
|
UI/UX: |
unset
|
Patch needs improvement: |
set
|
Owner: |
Mark Barrett removed
|
Patch needs improvement: |
unset
|
Status: |
assigned → new
|
Keywords: |
management django-admin.py manage.py added
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Explanation of changes in command_parser.diff: