Refs #24215 -- Fixed Python 3.5 compatiblity for unhandled lazy ops error.
This commit is contained in:
parent
da5747f8e4
commit
7506616f16
|
@ -381,6 +381,10 @@ class Apps(object):
|
||||||
|
|
||||||
def function(model):
|
def function(model):
|
||||||
next_function = partial(supplied_fn, model)
|
next_function = partial(supplied_fn, model)
|
||||||
|
# Annotate the function with its field for retrieval in
|
||||||
|
# migrations.state.StateApps.
|
||||||
|
if getattr(supplied_fn, 'keywords', None):
|
||||||
|
next_function.field = supplied_fn.keywords.get('field')
|
||||||
self.lazy_model_operation(next_function, *more_models)
|
self.lazy_model_operation(next_function, *more_models)
|
||||||
|
|
||||||
# If the model is already loaded, pass it to the function immediately.
|
# If the model is already loaded, pass it to the function immediately.
|
||||||
|
|
|
@ -244,11 +244,9 @@ class StateApps(Apps):
|
||||||
has a keyword argument called 'field'.
|
has a keyword argument called 'field'.
|
||||||
"""
|
"""
|
||||||
def extract_field(operation):
|
def extract_field(operation):
|
||||||
# Expect a functools.partial() with a kwarg called 'field' applied.
|
# operation is annotated with the field in
|
||||||
try:
|
# apps.register.Apps.lazy_model_operation().
|
||||||
return operation.func.keywords['field']
|
return getattr(operation, 'field', None)
|
||||||
except (AttributeError, KeyError):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def extract_field_names(operations):
|
def extract_field_names(operations):
|
||||||
return (str(field) for field in map(extract_field, operations) if field)
|
return (str(field) for field in map(extract_field, operations) if field)
|
||||||
|
|
Loading…
Reference in New Issue