1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Refs #23919 -- Removed misc Python 2/3 references.

This commit is contained in:
Tim Graham
2017-01-25 13:59:25 -05:00
committed by GitHub
parent 11856ea44e
commit 1c466994d9
22 changed files with 62 additions and 115 deletions

View File

@@ -322,8 +322,7 @@ class OracleParam:
param = Oracle_datetime.from_datetime(param)
string_size = 0
# Oracle doesn't recognize True and False correctly in Python 3.
# The conversion done below works both in 2 and 3.
# Oracle doesn't recognize True and False correctly.
if param is True:
param = 1
elif param is False:

View File

@@ -8,7 +8,6 @@ import math
import re
import types
import uuid
from importlib import import_module
from django.db import models
from django.db.migrations.operations.base import Operation
@@ -155,20 +154,15 @@ class FunctionTypeSerializer(BaseSerializer):
raise ValueError("Cannot serialize function: lambda")
if self.value.__module__ is None:
raise ValueError("Cannot serialize function %r: No module" % self.value)
# Python 3 is a lot easier, and only uses this branch if it's not local.
if getattr(self.value, "__qualname__", None) and getattr(self.value, "__module__", None):
if "<" not in self.value.__qualname__: # Qualname can include <locals>
return "%s.%s" % \
(self.value.__module__, self.value.__qualname__), {"import %s" % self.value.__module__}
# Fallback version
module_name = self.value.__module__
# Make sure it's actually there
module = import_module(module_name)
if not hasattr(module, self.value.__name__):
raise ValueError(
"Could not find function %s in %s.\n" % (self.value.__name__, module_name)
)
return "%s.%s" % (module_name, self.value.__name__), {"import %s" % module_name}
if '<' not in self.value.__qualname__: # Qualname can include <locals>
return '%s.%s' % (module_name, self.value.__qualname__), {'import %s' % self.value.__module__}
raise ValueError(
'Could not find function %s in %s.\n' % (self.value.__name__, module_name)
)
class FunctoolsPartialSerializer(BaseSerializer):