mirror of
https://github.com/django/django.git
synced 2025-09-27 04:29:17 +00:00
Refs #23919 -- Removed some Python 2 compatibility code and comments.
This commit is contained in:
parent
6585ebebaa
commit
ed0cbc8d8b
3 changed files with 6 additions and 19 deletions
|
@ -319,10 +319,9 @@ class QuerySet:
|
|||
if self.query.distinct_fields:
|
||||
raise NotImplementedError("aggregate() + distinct(fields) not implemented.")
|
||||
for arg in args:
|
||||
# The default_alias property may raise a TypeError, so we use
|
||||
# a try/except construct rather than hasattr in order to remain
|
||||
# consistent between PY2 and PY3 (hasattr would swallow
|
||||
# the TypeError on PY2).
|
||||
# The default_alias property raises TypeError if default_alias
|
||||
# can't be set automatically or AttributeError if it isn't an
|
||||
# attribute.
|
||||
try:
|
||||
arg.default_alias
|
||||
except (AttributeError, TypeError):
|
||||
|
@ -880,16 +879,13 @@ class QuerySet:
|
|||
"""
|
||||
annotations = OrderedDict() # To preserve ordering of args
|
||||
for arg in args:
|
||||
# The default_alias property may raise a TypeError, so we use
|
||||
# a try/except construct rather than hasattr in order to remain
|
||||
# consistent between PY2 and PY3 (hasattr would swallow
|
||||
# the TypeError on PY2).
|
||||
# The default_alias property may raise a TypeError.
|
||||
try:
|
||||
if arg.default_alias in kwargs:
|
||||
raise ValueError("The named annotation '%s' conflicts with the "
|
||||
"default name for another annotation."
|
||||
% arg.default_alias)
|
||||
except (AttributeError, TypeError):
|
||||
except TypeError:
|
||||
raise TypeError("Complex annotations require an alias")
|
||||
annotations[arg.default_alias] = arg
|
||||
annotations.update(kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue