Loading django/contrib/auth/management/__init__.py +2 −4 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ from django.core import exceptions from django.core.management.base import CommandError from django.db import DEFAULT_DB_ALIAS, router from django.db.models import get_models, signals from django.utils.encoding import DEFAULT_LOCALE_ENCODING from django.utils import six from django.utils.six.moves import input Loading Loading @@ -133,11 +134,8 @@ def get_system_username(): # (a very restricted chroot environment, for example). return '' if not six.PY3: default_locale = locale.getdefaultlocale()[1] if not default_locale: return '' try: result = result.decode(default_locale) result = result.decode(DEFAULT_LOCALE_ENCODING) except UnicodeDecodeError: # UnicodeDecodeError - preventive treatment for non-latin Windows. return '' Loading django/utils/encoding.py +14 −8 Original line number Diff line number Diff line Loading @@ -236,11 +236,17 @@ def filepath_to_uri(path): # some flexibility for hardcoding separators. return quote(force_bytes(path.replace("\\", "/")), safe=b"/~!*()'") # The encoding of the default system locale but falls back to the # given fallback encoding if the encoding is unsupported by python or could # not be determined. See tickets #10335 and #5846 def get_system_encoding(): """ The encoding of the default system locale but falls back to the given fallback encoding if the encoding is unsupported by python or could not be determined. See tickets #10335 and #5846 """ try: DEFAULT_LOCALE_ENCODING = locale.getdefaultlocale()[1] or 'ascii' codecs.lookup(DEFAULT_LOCALE_ENCODING) except: DEFAULT_LOCALE_ENCODING = 'ascii' encoding = locale.getdefaultlocale()[1] or 'ascii' codecs.lookup(encoding) except Exception: encoding = 'ascii' return encoding DEFAULT_LOCALE_ENCODING = get_system_encoding() Loading
django/contrib/auth/management/__init__.py +2 −4 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ from django.core import exceptions from django.core.management.base import CommandError from django.db import DEFAULT_DB_ALIAS, router from django.db.models import get_models, signals from django.utils.encoding import DEFAULT_LOCALE_ENCODING from django.utils import six from django.utils.six.moves import input Loading Loading @@ -133,11 +134,8 @@ def get_system_username(): # (a very restricted chroot environment, for example). return '' if not six.PY3: default_locale = locale.getdefaultlocale()[1] if not default_locale: return '' try: result = result.decode(default_locale) result = result.decode(DEFAULT_LOCALE_ENCODING) except UnicodeDecodeError: # UnicodeDecodeError - preventive treatment for non-latin Windows. return '' Loading
django/utils/encoding.py +14 −8 Original line number Diff line number Diff line Loading @@ -236,11 +236,17 @@ def filepath_to_uri(path): # some flexibility for hardcoding separators. return quote(force_bytes(path.replace("\\", "/")), safe=b"/~!*()'") # The encoding of the default system locale but falls back to the # given fallback encoding if the encoding is unsupported by python or could # not be determined. See tickets #10335 and #5846 def get_system_encoding(): """ The encoding of the default system locale but falls back to the given fallback encoding if the encoding is unsupported by python or could not be determined. See tickets #10335 and #5846 """ try: DEFAULT_LOCALE_ENCODING = locale.getdefaultlocale()[1] or 'ascii' codecs.lookup(DEFAULT_LOCALE_ENCODING) except: DEFAULT_LOCALE_ENCODING = 'ascii' encoding = locale.getdefaultlocale()[1] or 'ascii' codecs.lookup(encoding) except Exception: encoding = 'ascii' return encoding DEFAULT_LOCALE_ENCODING = get_system_encoding()