Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #9723 -- Not all Python distributions contain the bz2 module, s…

…o we need to allow for that. Based on a patch from AdamG.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9537 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 153b5a4a3aee057445b255ea387cd93dac2e5786 1 parent 8e68fc6
Malcolm Tredinnick authored December 01, 2008
9  django/core/management/commands/loaddata.py
@@ -10,6 +10,12 @@
10 10
 except NameError:
11 11
     from sets import Set as set   # Python 2.3 fallback
12 12
 
  13
+try:
  14
+    import bz2
  15
+    has_bz2 = True
  16
+except ImportError:
  17
+    has_bz2 = False
  18
+
13 19
 class Command(BaseCommand):
14 20
     help = 'Installs the named fixture(s) in the database.'
15 21
     args = "fixture [fixture ...]"
@@ -62,10 +68,11 @@ def read(self):
62 68
 
63 69
         compression_types = {
64 70
             None:   file,
65  
-            'bz2':  bz2.BZ2File,
66 71
             'gz':   gzip.GzipFile,
67 72
             'zip':  SingleZipReader
68 73
         }
  74
+        if has_bz2:
  75
+            compression_types['bz2'] = bz2.BZ2File
69 76
 
70 77
         app_fixtures = [os.path.join(os.path.dirname(app.__file__), 'fixtures') for app in get_apps()]
71 78
         for fixture_label in fixture_labels:

0 notes on commit 153b5a4

Please sign in to comment.
Something went wrong with that request. Please try again.