[Django] #32669: Fix for #32314 causing problems with non-package dotted name specified to -m

24 views
Skip to first unread message

Django

unread,
Apr 21, 2021, 3:22:33 AM4/21/21
to django-...@googlegroups.com
#32669: Fix for #32314 causing problems with non-package dotted name specified to
-m
-------------------------------------+-------------------------------------
Reporter: Moriyoshi | Owner: nobody
Koizumi |
Type: | Status: new
Uncategorized |
Component: Utilities | Version: 3.2
Severity: Normal | Keywords: autoreload
Triage Stage: | runserver
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The original fix [1] only attempted to deal with "-m foo.bar" where bar is
a package and __main__.py exists under foo/bar.

When a dotted name for a module (for example, foo.bar.baz where baz.py
resides under foo/bar) is specified like "-m foo.bar.baz", the resulting
arguments end up being "-m foo.bar", which is uncalled for.

[1]
https://github.com/django/django/commit/ec6d2531c59466924b645f314ac33f54470d7ac3

--
Ticket URL: <https://code.djangoproject.com/ticket/32669>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 21, 2021, 3:24:09 AM4/21/21
to django-...@googlegroups.com
#32669: Fix for #32314 causing problems with non-package dotted name specified to
-m
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: nobody
Type: Uncategorized | Status: new
Component: Utilities | Version: 3.2
Severity: Normal | Resolution:

Keywords: autoreload | Triage Stage:
runserver | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Moriyoshi Koizumi):

* Attachment "32669-autoreload-fix.patch.diff" added.

Patch

Django

unread,
Apr 21, 2021, 3:27:06 AM4/21/21
to django-...@googlegroups.com
#32669: Fix for #32314 causing problems with non-package dotted name specified to
-m
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: nobody
Type: Uncategorized | Status: new
Component: Utilities | Version: 3.2
Severity: Normal | Resolution:

Keywords: autoreload | Triage Stage:
runserver | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Moriyoshi Koizumi:

Old description:

> The original fix [1] only attempted to deal with "-m foo.bar" where bar
> is a package and __main__.py exists under foo/bar.
>
> When a dotted name for a module (for example, foo.bar.baz where baz.py
> resides under foo/bar) is specified like "-m foo.bar.baz", the resulting
> arguments end up being "-m foo.bar", which is uncalled for.
>
> [1]
> https://github.com/django/django/commit/ec6d2531c59466924b645f314ac33f54470d7ac3

New description:

The original fix [1] only attempted to deal with `-m foo.bar` where `bar`

is a package and `__main__.py` exists under `foo/bar`.

When a dotted name for a module (for example, `foo.bar.baz` where `baz.py`

resides under `foo/bar`) is specified like `-m foo.bar.baz`, the resulting


arguments end up being `-m foo.bar`, which is uncalled for.

[1]
https://github.com/django/django/commit/ec6d2531c59466924b645f314ac33f54470d7ac3

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:1>

Django

unread,
Apr 21, 2021, 4:30:12 AM4/21/21
to django-...@googlegroups.com
#32669: Allow autoreloading of `python -m custom_module runserver`
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: Moriyoshi
| Koizumi
Type: New feature | Status: assigned
Component: Utilities | Version: 4.0
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage: Accepted
runserver |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => assigned
* cc: William Schwartz (added)
* version: 3.2 => 4.0
* owner: nobody => Moriyoshi Koizumi
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


Old description:

> The original fix [1] only attempted to deal with `-m foo.bar` where `bar`

> is a package and `__main__.py` exists under `foo/bar`.


>
> When a dotted name for a module (for example, `foo.bar.baz` where

> `baz.py` resides under `foo/bar`) is specified like `-m foo.bar.baz`, the


> resulting arguments end up being `-m foo.bar`, which is uncalled for.
>
> [1]
> https://github.com/django/django/commit/ec6d2531c59466924b645f314ac33f54470d7ac3

New description:

The original fix [1] only attempted to deal with `-m foo.bar` where `bar`

is a package and `__main__.py` exists under `foo/bar`.

When a dotted name for a module (for example, `foo.bar.baz` where `baz.py`

resides under `foo/bar`) is specified like `-m foo.bar.baz`, the resulting


arguments end up being `-m foo.bar`, which is uncalled for.

[1]
https://github.com/django/django/commit/ec6d2531c59466924b645f314ac33f54470d7ac3

Fixed detection when started non-django modules with "python -m" in
autoreloader.

--

Comment:

It doesn't work in Django 3.1 so I would not call it a regression.

Can you send PR via GitHub?

--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:2>

Django

unread,
Apr 21, 2021, 9:29:27 AM4/21/21
to django-...@googlegroups.com
#32669: Allow autoreloading of `python -m custom_module runserver`
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: Moriyoshi
| Koizumi
Type: New feature | Status: assigned
Component: Utilities | Version: 4.0
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage: Accepted
runserver |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by William Schwartz):

Looks fine. The one change I'd make is that I'd change

{{{#!python
modspec.name.split(".")[-1] == "__main__"
}}}

to

{{{#!python
modspec.name == "__main__" or modspec.name.endswith(".__main__")
}}}

to avoid dumb corner cases like a module named `foo.my__main__` (which is
how
[https://github.com/python/cpython/blob/fa03efda3dc6ad118788bebc61079cd481c0b24c/Lib/runpy.py#L143
runpy.py] itself deals with it).

--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:3>

Django

unread,
Apr 24, 2021, 10:45:03 PM4/24/21
to django-...@googlegroups.com
#32669: Allow autoreloading of `python -m custom_module runserver`
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: Moriyoshi
| Koizumi
Type: New feature | Status: assigned
Component: Utilities | Version: 4.0
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage: Accepted
runserver |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Moriyoshi Koizumi):

> It doesn't work in Django 3.1 so I would not call it a regression.
> Can you send PR via GitHub?

I put manage.py under some package like `foo/bar/manage.py` and run it
like `-m foo.bar.manage runserver ...`. This used to run perfectly on
3.1.

--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:4>

Django

unread,
Apr 24, 2021, 10:54:49 PM4/24/21
to django-...@googlegroups.com
#32669: Allow autoreloading of `python -m custom_module runserver`
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: Moriyoshi
| Koizumi
Type: New feature | Status: assigned
Component: Utilities | Version: 4.0
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage: Accepted
runserver |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Moriyoshi Koizumi):

https://github.com/django/django/pull/14311

--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:5>

Django

unread,
Apr 26, 2021, 1:57:25 AM4/26/21
to django-...@googlegroups.com
#32669: Allow autoreloading of `python -m custom_module runserver`
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: Moriyoshi
| Koizumi
Type: New feature | Status: assigned
Component: Utilities | Version: 4.0
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage: Accepted
runserver |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:4 Moriyoshi Koizumi]:


> I put manage.py under some package like `foo/bar/manage.py` and run it
like `-m foo.bar.manage runserver ...`. This used to run perfectly on
3.1.

Can you attach a sample project? It raises `ModuleNotFoundError` for me.

--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:6>

Django

unread,
Apr 28, 2021, 2:00:50 AM4/28/21
to django-...@googlegroups.com
#32669: Allow autoreloading of `python -m custom_module runserver`
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: Moriyoshi
| Koizumi
Type: New feature | Status: assigned
Component: Utilities | Version: 4.0
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage: Accepted
runserver |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:7>

Django

unread,
May 26, 2021, 6:32:37 AM5/26/21
to django-...@googlegroups.com
#32669: Allow autoreloading of `python -m custom_module runserver`
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: Moriyoshi
| Koizumi
Type: New feature | Status: assigned
Component: Utilities | Version: 4.0
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage: Ready for
runserver | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:8>

Django

unread,
May 26, 2021, 7:08:13 AM5/26/21
to django-...@googlegroups.com
#32669: Allow autoreloading of `python -m custom_module runserver`
-------------------------------------+-------------------------------------
Reporter: Moriyoshi Koizumi | Owner: Moriyoshi
| Koizumi
Type: New feature | Status: closed
Component: Utilities | Version: 4.0
Severity: Normal | Resolution: fixed

Keywords: autoreload | Triage Stage: Ready for
runserver | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"9e4780dedac15adcc04309d0198f4ae34e04cc2a" 9e4780de]:
{{{
#!CommitTicketReference repository=""
revision="9e4780dedac15adcc04309d0198f4ae34e04cc2a"
Fixed #32669 -- Fixed detection when started non-django modules which
aren't packages with "python -m" in autoreloader.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32669#comment:9>

Reply all
Reply to author
Forward
0 new messages