summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Michaud <pmichaud@uw.edu>2014-03-22 16:52:05 +0100
committerClaude Paroz <claude@2xlibre.net>2014-04-01 20:45:12 +0200
commit73474df9541bd5fabbf419debc5d72c09619f625 (patch)
treeeaaae97565fd01ae03af44d26c0f2c7d20bb2ef4
parent07e2a5681435e493be93dceac611c3870ae6b1c6 (diff)
Fixed #22256 -- Replaced bad fallback for missing PATH
Thanks Baptiste Mispelon for the review. Backport of acee46fc9 from master.
-rw-r--r--django/core/management/utils.py2
-rw-r--r--docs/releases/1.6.3.txt4
-rw-r--r--tests/user_commands/tests.py16
3 files changed, 20 insertions, 2 deletions
diff --git a/django/core/management/utils.py b/django/core/management/utils.py
index 7159d1123f..a8959e8150 100644
--- a/django/core/management/utils.py
+++ b/django/core/management/utils.py
@@ -56,7 +56,7 @@ def handle_extensions(extensions=('html',), ignored=('py',)):
def find_command(cmd, path=None, pathext=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):
path = [path]
# check if there are funny path extensions for executables, e.g. Windows
diff --git a/docs/releases/1.6.3.txt b/docs/releases/1.6.3.txt
index 863cbf2ab2..ca9069d250 100644
--- a/docs/releases/1.6.3.txt
+++ b/docs/releases/1.6.3.txt
@@ -34,5 +34,9 @@ several bugs in 1.6.2:
<django.contrib.admin.ModelAdmin.preserve_filters>` when running a site with
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
upgraded to the latest release (1.6.1).
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index bf555e66b9..c24a6e7a2d 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -1,8 +1,9 @@
+import os
import sys
from django.core import management
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.utils import translation
from django.utils.six import StringIO
@@ -60,6 +61,19 @@ class CommandTests(SimpleTestCase):
management.call_command('leave_locale_alone_true', stdout=out)
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):