Changes between Initial Version and Version 2 of Ticket #32314


Ignore:
Timestamp:
Jan 4, 2021, 11:45:52 AM (4 years ago)
Author:
William Schwartz
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32314

    • Property Owner changed from nobody to William Schwartz
  • Ticket #32314 – Description

    initial v2  
    11[https://github.com/django/django/blob/b41d38ae26b1da9519a6cd765bc2f2ce7d355007/django/utils/autoreload.py#L213-L246 django.utils.autoreload.get_child_arguments] detects if Python was launched as `python -m django`. Currently it detects only when [https://docs.python.org/3/using/cmdline.html#cmdoption-m -m] was passed specifically `django` (and only in Python environments in which `__file__` is set on modules, which is [https://docs.python.org/3/reference/import.html#__file__ not true of all Python environments]). Like #32177, this ticket aims to remove one impediment to creating Django-based command-line utilities that have their own [https://docs.python.org/3/library/__main__.html __main__ sub-module] while overriding Django's built-in management commands—in this case, `runserver`.
    22
    3 The fix, which I will submit as a PR shortly, is to use Python's [https://docs.python.org/3/reference/import.html#main-spec documented] way of determining if `-m` was used in `get_child_arguments`:
     3The fix, which I have submitted in the [https://github.com/django/django/pull/13837 attached PR], is to use Python's [https://docs.python.org/3/reference/import.html#main-spec documented] way of determining if `-m` was used in `get_child_arguments`:
    44* The top-level `__main__` module is always the entry point of a [https://docs.python.org/3/reference/toplevel_components.html#complete-python-programs complete Python program].
    55*  `__main__.__spec__` is not `None` [https://docs.python.org/3/reference/import.html#main-spec if and only if] Python was launched with `-m` or the name of a "directory, zipfile or other `sys.path` entry." In the latter cases, the [https://docs.python.org/3/using/cmdline.html#cmdarg-script documentation says]
Back to Top