﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24769	Cast optparse verbosity argument to an integer for better backwards compatibility	Daniel Hahler	nobody	"With Django 1.8 and Python 3.4.3, I see the following error:

    {{{
    % manage.py test
    ...
      File ""…/django18/django/core/management/commands/test.py"", line 65, in execute
        if options['verbosity'] > 0:
    TypeError: unorderable types: str() > int()
    }}}

It appears to stem from the optparse parser being used (because
BaseCommand.option_list is non-empty (for --pdb and --ipdb)):

    {{{
    parser.add_option('-v', '--verbosity', action='store', dest='verbosity', default='1',
        type='choice', choices=['0', '1', '2', '3'],
        help='Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output')
    }}}

The type ""choice"" is a subtype of ""string"" options (https://docs.python.org/2/library/optparse.html).

It seems like this option whould need to be casted to an `int` after parsing.

This was added in 85686386 (#19973).

    {{{
    Traceback (most recent call last):
      File ""…/bin/manage.py"", line 37, in <module>
        execute_from_command_line(sys.argv)
      File ""…/django18/django/core/management/__init__.py"", line 338, in execute_from_command_line
        utility.execute()
      File ""…/django18/django/core/management/__init__.py"", line 330, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File ""…/django18/django/core/management/commands/test.py"", line 30, in run_from_argv
        super(Command, self).run_from_argv(argv)
      File ""…/django18/django/core/management/base.py"", line 390, in run_from_argv
        self.execute(*args, **cmd_options)
      File ""…/django18/django/core/management/commands/test.py"", line 65, in execute
        if options['verbosity'] > 0:
    TypeError: unorderable types: str() > int()
    }}}

I have not tried it with Django master, because there are several other problems.

In case it has been fixed there already, I'd say that this is something that should get backported."	Cleanup/optimization	closed	Core (Management commands)	1.8	Normal	fixed			Accepted	1	0	1	0	0	0
