mirror of https://github.com/django/django.git
Fixed #22256 -- Replaced bad fallback for missing PATH
Thanks Baptiste Mispelon for the review.
Backport of acee46fc9
from master.
This commit is contained in:
parent
07e2a56814
commit
73474df954
|
@ -56,7 +56,7 @@ def handle_extensions(extensions=('html',), ignored=('py',)):
|
||||||
|
|
||||||
def find_command(cmd, path=None, pathext=None):
|
def find_command(cmd, path=None, pathext=None):
|
||||||
if path is None:
|
if path is None:
|
||||||
path = os.environ.get('PATH', []).split(os.pathsep)
|
path = os.environ.get('PATH', '').split(os.pathsep)
|
||||||
if isinstance(path, six.string_types):
|
if isinstance(path, six.string_types):
|
||||||
path = [path]
|
path = [path]
|
||||||
# check if there are funny path extensions for executables, e.g. Windows
|
# check if there are funny path extensions for executables, e.g. Windows
|
||||||
|
|
|
@ -34,5 +34,9 @@ several bugs in 1.6.2:
|
||||||
<django.contrib.admin.ModelAdmin.preserve_filters>` when running a site with
|
<django.contrib.admin.ModelAdmin.preserve_filters>` when running a site with
|
||||||
a URL prefix (`#21795 <http://code.djangoproject.com/ticket/21795>`_).
|
a URL prefix (`#21795 <http://code.djangoproject.com/ticket/21795>`_).
|
||||||
|
|
||||||
|
* Fixed a crash in the ``find_command`` management utility when the ``PATH``
|
||||||
|
environment variable wasn't set
|
||||||
|
(`#22256 <http://code.djangoproject.com/ticket/22256>`_).
|
||||||
|
|
||||||
Additionally, Django's vendored version of six, :mod:`django.utils.six` has been
|
Additionally, Django's vendored version of six, :mod:`django.utils.six` has been
|
||||||
upgraded to the latest release (1.6.1).
|
upgraded to the latest release (1.6.1).
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django.core import management
|
from django.core import management
|
||||||
from django.core.management import CommandError
|
from django.core.management import CommandError
|
||||||
from django.core.management.utils import popen_wrapper
|
from django.core.management.utils import find_command, popen_wrapper
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
from django.utils.six import StringIO
|
from django.utils.six import StringIO
|
||||||
|
@ -60,6 +61,19 @@ class CommandTests(SimpleTestCase):
|
||||||
management.call_command('leave_locale_alone_true', stdout=out)
|
management.call_command('leave_locale_alone_true', stdout=out)
|
||||||
self.assertEqual(out.getvalue(), "pl\n")
|
self.assertEqual(out.getvalue(), "pl\n")
|
||||||
|
|
||||||
|
def test_find_command_without_PATH(self):
|
||||||
|
"""
|
||||||
|
find_command should still work when the PATH environment variable
|
||||||
|
doesn't exist (#22256).
|
||||||
|
"""
|
||||||
|
current_path = os.environ.pop('PATH', None)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.assertIsNone(find_command('_missing_'))
|
||||||
|
finally:
|
||||||
|
if current_path is not None:
|
||||||
|
os.environ['PATH'] = current_path
|
||||||
|
|
||||||
|
|
||||||
class UtilsTests(SimpleTestCase):
|
class UtilsTests(SimpleTestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue