From 16942e178f713537ba3d341192019cfd2874d89e Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 16 Feb 2010 12:16:01 +0000 Subject: [PATCH] Removed Python 2.3 compat code in translation framework. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12446 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../management/commands/compilemessages.py | 5 ---- django/utils/translation/trans_real.py | 26 ++----------------- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/django/core/management/commands/compilemessages.py b/django/core/management/commands/compilemessages.py index d1f1647f8b..7d600e0fe9 100644 --- a/django/core/management/commands/compilemessages.py +++ b/django/core/management/commands/compilemessages.py @@ -3,11 +3,6 @@ import sys from optparse import make_option from django.core.management.base import BaseCommand, CommandError -try: - set -except NameError: - from sets import Set as set # For Python 2.3 - def compile_messages(locale=None): basedirs = [os.path.join('conf', 'locale'), 'locale'] if os.environ.get('DJANGO_SETTINGS_MODULE'): diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 42e3bcc0d7..e6e0a61201 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -60,7 +60,7 @@ class DjangoTranslation(gettext_module.GNUTranslations): """ This class sets up the GNUTranslations context with regard to output charset. Django uses a defined DEFAULT_CHARSET as the output charset on - Python 2.4. With Python 2.3, use DjangoTranslation23. + Python 2.4. """ def __init__(self, *args, **kw): from django.conf import settings @@ -87,23 +87,6 @@ class DjangoTranslation(gettext_module.GNUTranslations): def __repr__(self): return "" % self.__language -class DjangoTranslation23(DjangoTranslation): - """ - Compatibility class that is only used with Python 2.3. - Python 2.3 doesn't support set_output_charset on translation objects and - needs this wrapper class to make sure input charsets from translation files - are correctly translated to output charsets. - - With a full switch to Python 2.4, this can be removed from the source. - """ - def gettext(self, msgid): - res = self.ugettext(msgid) - return res.encode(self.django_output_charset) - - def ngettext(self, msgid1, msgid2, n): - res = self.ungettext(msgid1, msgid2, n) - return res.encode(self.django_output_charset) - def translation(language): """ Returns a translation object. @@ -121,11 +104,6 @@ def translation(language): from django.conf import settings - # set up the right translation class - klass = DjangoTranslation - if sys.version_info < (2, 4): - klass = DjangoTranslation23 - globalpath = os.path.join(os.path.dirname(sys.modules[settings.__module__].__file__), 'locale') if settings.SETTINGS_MODULE is not None: @@ -147,7 +125,7 @@ def translation(language): def _translation(path): try: - t = gettext_module.translation('django', path, [loc], klass) + t = gettext_module.translation('django', path, [loc], DjangoTranslation) t.set_language(lang) return t except IOError, e: