diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-01-19 17:14:31 +0000 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-01-19 17:14:31 +0000 |
| commit | 1ea96acaf56acee692fe6f5668644962231be5e1 (patch) | |
| tree | d3f1a97ffd5113b161039740b5127702ccdcfd32 | |
| parent | e802c97581594e3a37e6497443b105ecb9920a55 (diff) | |
Fix unicode default input on py3
| -rw-r--r-- | django/db/migrations/questioner.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/django/db/migrations/questioner.py b/django/db/migrations/questioner.py index ae75b47d03..d2e63659a2 100644 --- a/django/db/migrations/questioner.py +++ b/django/db/migrations/questioner.py @@ -3,7 +3,7 @@ import os import sys from django.apps import apps -from django.utils import datetime_safe +from django.utils import datetime_safe, six from django.utils.six.moves import input from .loader import MIGRATIONS_MODULE_NAME @@ -97,7 +97,13 @@ class InteractiveMigrationQuestioner(MigrationQuestioner): print("Please enter the default value now, as valid Python") print("The datetime module is available, so you can do e.g. datetime.date.today()") while True: - code = input(">>> ").decode(sys.stdin.encoding) + if six.PY3: + # Six does not correctly abstract over the fact that + # py3 input returns a unicode string, while py2 raw_input + # returns a bytestring. + code = input(">>> ") + else: + code = input(">>> ").decode(sys.stdin.encoding) if not code: print("Please enter some code, or 'exit' (with no quotes) to exit.") elif code == "exit": |
