summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Allred <aallred@rsglab.com>2018-10-17 19:47:20 -0400
committerTim Graham <timograham@gmail.com>2018-10-19 20:45:55 -0400
commit0d5d8ed32213a84189c2bf436c88806b77b6785b (patch)
tree07e1931adef3972c7503a0ea63a7569830d45f97
parent4acdba42a632ef78959f67f57fab10899fefb8e6 (diff)
[2.1.x] Fixed #29774 -- Fixed django-admin shell hang on startup.
sys.stdin.read() blocks waiting for EOF in shell.py which will likely never come if the user provides input on stdin via the keyboard before the shell starts. Added check for a tty to skip reading stdin if it's not present. This still allows piping of code into the shell (which should have no TTY and should have an EOF) but also doesn't cause it to hang if multi-line input is provided. Backport of 4e78e389b16fbceb23d5236ee1650b213e71c968 from master.
-rw-r--r--AUTHORS1
-rw-r--r--django/core/management/commands/shell.py2
-rw-r--r--docs/releases/2.1.3.txt3
3 files changed, 5 insertions, 1 deletions
diff --git a/AUTHORS b/AUTHORS
index dd7d7a2081..7ae9f15acc 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,6 +10,7 @@ answer newbie questions, and generally made Django that much better:
Aaron T. Myers <atmyers@gmail.com>
Abeer Upadhyay <ab.esquarer@gmail.com>
Abhishek Gautam <abhishekg1128@yahoo.com>
+ Adam Allred <adam.w.allred@gmail.com>
Adam BogdaƂ <adam@bogdal.pl>
Adam Donaghy
Adam Johnson <https://github.com/adamchainz>
diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
index 7c9a43434a..e85f7ac12e 100644
--- a/django/core/management/commands/shell.py
+++ b/django/core/management/commands/shell.py
@@ -88,7 +88,7 @@ class Command(BaseCommand):
# Execute stdin if it has anything to read and exit.
# Not supported on Windows due to select.select() limitations.
- if sys.platform != 'win32' and select.select([sys.stdin], [], [], 0)[0]:
+ if sys.platform != 'win32' and not sys.stdin.isatty() and select.select([sys.stdin], [], [], 0)[0]:
exec(sys.stdin.read())
return
diff --git a/docs/releases/2.1.3.txt b/docs/releases/2.1.3.txt
index 15e53db65b..7e0446219e 100644
--- a/docs/releases/2.1.3.txt
+++ b/docs/releases/2.1.3.txt
@@ -11,3 +11,6 @@ Bugfixes
* Fixed a regression in Django 2.0 where combining ``Q`` objects with ``__in``
lookups and lists crashed (:ticket:`29838`).
+
+* Fixed a regression in Django 1.11 where ``django-admin shell`` may hang
+ on startup (:ticket:`29774`).