Fixed #32202 -- Fixed autoreloader argument generation for Windows with Python 3.7-.
This commit is contained in:
parent
9f72b0970d
commit
ead37dfb58
|
@ -232,11 +232,15 @@ def get_child_arguments():
|
|||
exe_entrypoint = py_script.with_suffix('.exe')
|
||||
if exe_entrypoint.exists():
|
||||
# Should be executed directly, ignoring sys.executable.
|
||||
return [exe_entrypoint, *sys.argv[1:]]
|
||||
# TODO: Remove str() when dropping support for PY37.
|
||||
# args parameter accepts path-like on Windows from Python 3.8.
|
||||
return [str(exe_entrypoint), *sys.argv[1:]]
|
||||
script_entrypoint = py_script.with_name('%s-script.py' % py_script.name)
|
||||
if script_entrypoint.exists():
|
||||
# Should be executed as usual.
|
||||
return [*args, script_entrypoint, *sys.argv[1:]]
|
||||
# TODO: Remove str() when dropping support for PY37.
|
||||
# args parameter accepts path-like on Windows from Python 3.8.
|
||||
return [*args, str(script_entrypoint), *sys.argv[1:]]
|
||||
raise RuntimeError('Script %s does not exist.' % py_script)
|
||||
else:
|
||||
args += sys.argv
|
||||
|
|
|
@ -17,3 +17,7 @@ Bugfixes
|
|||
|
||||
* Fixed crash of key transforms for :class:`~django.db.models.JSONField` on
|
||||
PostgreSQL when using on a ``Subquery()`` annotation (:ticket:`32182`).
|
||||
|
||||
* Fixed a regression in Django 3.1 that caused a crash of auto-reloader for
|
||||
certain invocations of ``runserver`` on Windows with Python 3.7 and below
|
||||
(:ticket:`32202`).
|
||||
|
|
|
@ -178,10 +178,10 @@ class TestChildArguments(SimpleTestCase):
|
|||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
exe_path = Path(tmpdir) / 'django-admin.exe'
|
||||
exe_path.touch()
|
||||
with mock.patch('sys.argv', [exe_path.with_suffix(''), 'runserver']):
|
||||
with mock.patch('sys.argv', [str(exe_path.with_suffix('')), 'runserver']):
|
||||
self.assertEqual(
|
||||
autoreload.get_child_arguments(),
|
||||
[exe_path, 'runserver']
|
||||
[str(exe_path), 'runserver']
|
||||
)
|
||||
|
||||
@mock.patch('sys.warnoptions', [])
|
||||
|
@ -189,10 +189,10 @@ class TestChildArguments(SimpleTestCase):
|
|||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
script_path = Path(tmpdir) / 'django-admin-script.py'
|
||||
script_path.touch()
|
||||
with mock.patch('sys.argv', [script_path.with_name('django-admin'), 'runserver']):
|
||||
with mock.patch('sys.argv', [str(script_path.with_name('django-admin')), 'runserver']):
|
||||
self.assertEqual(
|
||||
autoreload.get_child_arguments(),
|
||||
[sys.executable, script_path, 'runserver']
|
||||
[sys.executable, str(script_path), 'runserver']
|
||||
)
|
||||
|
||||
@mock.patch('sys.argv', ['does-not-exist', 'runserver'])
|
||||
|
@ -433,7 +433,7 @@ class RestartWithReloaderTests(SimpleTestCase):
|
|||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
script = Path(temp_dir) / 'manage.py'
|
||||
script.touch()
|
||||
argv = [script, 'runserver']
|
||||
argv = [str(script), 'runserver']
|
||||
mock_call = self.patch_autoreload(argv)
|
||||
autoreload.restart_with_reloader()
|
||||
self.assertEqual(mock_call.call_count, 1)
|
||||
|
|
Loading…
Reference in New Issue