Refs #23919 -- Removed enum ImportError handling for Python 2.

This commit is contained in:
Tim Graham 2017-01-19 13:55:20 -05:00
parent d29fd3f9a6
commit 9ee47ce7b4
3 changed files with 3 additions and 20 deletions

View File

@ -2,6 +2,7 @@ import builtins
import collections
import datetime
import decimal
import enum
import functools
import math
import types
@ -17,12 +18,6 @@ from django.utils.functional import LazyObject, Promise
from django.utils.timezone import utc
from django.utils.version import get_docs_version
try:
import enum
except ImportError:
# No support on Python 2 if enum34 isn't installed.
enum = None
class BaseSerializer:
def __init__(self, value):
@ -349,7 +344,7 @@ def serializer_factory(value):
return TupleSerializer(value)
if isinstance(value, dict):
return DictionarySerializer(value)
if enum and isinstance(value, enum.Enum):
if isinstance(value, enum.Enum):
return EnumSerializer(value)
if isinstance(value, datetime.datetime):
return DatetimeSerializer(value)

View File

@ -13,12 +13,6 @@ from django.utils.inspect import get_func_args
from django.utils.module_loading import module_dir
from django.utils.timezone import now
try:
import enum
except ImportError:
# No support on Python 2 if enum34 isn't installed.
enum = None
class SettingsReference(str):
"""

View File

@ -1,12 +1,12 @@
import datetime
import decimal
import enum
import functools
import math
import os
import re
import sys
import tokenize
import unittest
import uuid
from io import StringIO
@ -31,11 +31,6 @@ from django.utils.translation import ugettext_lazy as _
from .models import FoodManager, FoodQuerySet
try:
import enum
except ImportError:
enum = None
PY36 = sys.version_info >= (3, 6)
@ -259,7 +254,6 @@ class WriterTests(SimpleTestCase):
lazy_pattern = SimpleLazyObject(lambda: pattern)
self.assertEqual(self.serialize_round_trip(lazy_pattern), pattern)
@unittest.skipUnless(enum, "enum34 is required on Python 2")
def test_serialize_enums(self):
class TextEnum(enum.Enum):
A = 'a-value'