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')
|
exe_entrypoint = py_script.with_suffix('.exe')
|
||||||
if exe_entrypoint.exists():
|
if exe_entrypoint.exists():
|
||||||
# Should be executed directly, ignoring sys.executable.
|
# 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)
|
script_entrypoint = py_script.with_name('%s-script.py' % py_script.name)
|
||||||
if script_entrypoint.exists():
|
if script_entrypoint.exists():
|
||||||
# Should be executed as usual.
|
# 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)
|
raise RuntimeError('Script %s does not exist.' % py_script)
|
||||||
else:
|
else:
|
||||||
args += sys.argv
|
args += sys.argv
|
||||||
|
|
|
@ -17,3 +17,7 @@ Bugfixes
|
||||||
|
|
||||||
* Fixed crash of key transforms for :class:`~django.db.models.JSONField` on
|
* Fixed crash of key transforms for :class:`~django.db.models.JSONField` on
|
||||||
PostgreSQL when using on a ``Subquery()`` annotation (:ticket:`32182`).
|
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:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
exe_path = Path(tmpdir) / 'django-admin.exe'
|
exe_path = Path(tmpdir) / 'django-admin.exe'
|
||||||
exe_path.touch()
|
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(
|
self.assertEqual(
|
||||||
autoreload.get_child_arguments(),
|
autoreload.get_child_arguments(),
|
||||||
[exe_path, 'runserver']
|
[str(exe_path), 'runserver']
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch('sys.warnoptions', [])
|
@mock.patch('sys.warnoptions', [])
|
||||||
|
@ -189,10 +189,10 @@ class TestChildArguments(SimpleTestCase):
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
script_path = Path(tmpdir) / 'django-admin-script.py'
|
script_path = Path(tmpdir) / 'django-admin-script.py'
|
||||||
script_path.touch()
|
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(
|
self.assertEqual(
|
||||||
autoreload.get_child_arguments(),
|
autoreload.get_child_arguments(),
|
||||||
[sys.executable, script_path, 'runserver']
|
[sys.executable, str(script_path), 'runserver']
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch('sys.argv', ['does-not-exist', 'runserver'])
|
@mock.patch('sys.argv', ['does-not-exist', 'runserver'])
|
||||||
|
@ -433,7 +433,7 @@ class RestartWithReloaderTests(SimpleTestCase):
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
script = Path(temp_dir) / 'manage.py'
|
script = Path(temp_dir) / 'manage.py'
|
||||||
script.touch()
|
script.touch()
|
||||||
argv = [script, 'runserver']
|
argv = [str(script), 'runserver']
|
||||||
mock_call = self.patch_autoreload(argv)
|
mock_call = self.patch_autoreload(argv)
|
||||||
autoreload.restart_with_reloader()
|
autoreload.restart_with_reloader()
|
||||||
self.assertEqual(mock_call.call_count, 1)
|
self.assertEqual(mock_call.call_count, 1)
|
||||||
|
|
Loading…
Reference in New Issue