diff options
| author | Claude Paroz <claude@2xlibre.net> | 2015-01-02 17:58:58 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-01-05 17:19:35 +0100 |
| commit | 6e1c9c6568c405bfa481dda4249abe2960173547 (patch) | |
| tree | 12810d919e3f0e35cd8e277ec996fb9e851a786e /django | |
| parent | d94fe42ae5e67e9fd600d204a08eef00cc10a7df (diff) | |
Fixed #8280 -- Allowed management command discovery for eggs
Thanks jdetaeye for the report, bhuztez and jdetaeye for the
initial patches, Tim Graham and Berker Peksag for the reviews.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/__init__.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index b88026a335..a0c86024b9 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import collections from importlib import import_module import os +import pkgutil import sys import django @@ -24,11 +25,10 @@ def find_commands(management_dir): Returns an empty list if no commands are defined. """ command_dir = os.path.join(management_dir, 'commands') - try: - return [f[:-3] for f in os.listdir(command_dir) - if not f.startswith('_') and f.endswith('.py')] - except OSError: - return [] + # Workaround for a Python 3.2 bug with pkgutil.iter_modules + sys.path_importer_cache.pop(command_dir, None) + return [name for _, name, is_pkg in pkgutil.iter_modules([command_dir]) + if not is_pkg and not name.startswith('_')] def load_command_class(app_name, name): |
