summaryrefslogtreecommitdiff
path: root/django/apps
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-12-30 17:00:50 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-12-30 22:10:04 +0100
commitd6dc88cbc1ebc4cfba6faf39edf6eebd41873029 (patch)
tree93292eb15764689ce18b6b0496292266d554367a /django/apps
parente5c89c62f2ea0b4d873eea8945d61cec3ba82673 (diff)
Avoided leaking state on exceptions in populate_models().
Diffstat (limited to 'django/apps')
-rw-r--r--django/apps/registry.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/django/apps/registry.py b/django/apps/registry.py
index 5dbb4696d7..1bb00f37f7 100644
--- a/django/apps/registry.py
+++ b/django/apps/registry.py
@@ -125,11 +125,12 @@ class Apps(object):
self._postponed.append(app_config)
if outermost:
- for app_config in self._postponed:
- all_models = self.all_models[app_config.label]
- app_config.import_models(all_models)
-
- del self._postponed
+ try:
+ for app_config in self._postponed:
+ all_models = self.all_models[app_config.label]
+ app_config.import_models(all_models)
+ finally:
+ del self._postponed
self.clear_cache()
self._models_loaded = True