Browse files

Avoided leaking state on exceptions in populate_models().

  • Loading branch information...
1 parent e5c89c6 commit d6dc88cbc1ebc4cfba6faf39edf6eebd41873029 @aaugustin aaugustin committed Dec 30, 2013
Showing with 6 additions and 5 deletions.
  1. +6 −5 django/apps/registry.py
View
11 django/apps/registry.py
@@ -125,11 +125,12 @@ def populate_models(self):
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

0 comments on commit d6dc88c

Please sign in to comment.