#32177: ManagementUtility instantiates CommandParser without passing already- computed prog argument -------------------------------------+------------------------------------- Reporter: William Schwartz | Owner: Douglas | Cueva Type: Bug | Status: assigned Component: Core (Management | Version: master commands) | Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 1 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by William Schwartz):
* needs_tests: 1 => 0 Comment: Replying to [comment:2 Mariusz Felisiak]: > ...I was not able to reproduce and invalid message (even with mocking `sys.argv`), so a regression test is crucial. I've created a patch with a test case in [https://github.com/django/django/pull/13658 PR]. (I didn't see Douglas Cueva's patch GH-13652 before I pushed mine. Sorry.) Is this a backport candidate? The [https://github.com/wkschwartz/django/blob/c8a6dab82841abb43dfc7dc8859482d329c8334a/tests/admin_scripts/tests.py#L1868-L1882 test I added] passes now, and failed like below before I applied the fix. {{{ (venv) ➜ django git:(mgmt-argv0) ✗ tox -e py38 -- admin_scripts.tests.ExecuteFromCommandLine <snip> py38 run-test: commands[0] | django/.tox/py38/bin/python runtests.py admin_scripts.tests.ExecuteFromCommandLine Testing against Django installed in 'django/django' System check identified no issues (0 silenced). E ====================================================================== ERROR: test_prog_name_from_argv0 (admin_scripts.tests.ExecuteFromCommandLine) Program name is computed once from argv argument, not sys.argv (#32177). ---------------------------------------------------------------------- Traceback (most recent call last): File "django/tests/admin_scripts/tests.py", line 1882, in test_prog_name_from_argv0 execute_from_command_line([''] + args) File "django/django/core/management/__init__.py", line 414, in execute_from_command_line utility.execute() File "django/django/core/management/__init__.py", line 347, in execute parser = CommandParser(usage='%(prog)s subcommand [options] [args]', add_help=False, allow_abbrev=False) File "django/django/core/management/base.py", line 54, in __init__ super().__init__(**kwargs) File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/argparse.py", line 1660, in __init__ prog = _os.path.basename(_sys.argv[0]) File "/usr/local/opt/python@3.8/bin/../Frameworks/Python.framework/Versions/3.8/lib/python3.8/posixpath.py", line 142, in basename p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType ---------------------------------------------------------------------- Ran 1 test in 0.005s FAILED (errors=1) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/32177#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.29ec97610c6c3f5995c9f8f62c867efc%40djangoproject.com.