Ticket #9723: fix-r9527-loaddata-bz2.patch

File fix-r9527-loaddata-bz2.patch, 859 bytes (added by AdamG, 7 years ago)

Patch to catch the ImportError if bz2 is not compiled in

  • django/core/management/commands/loaddata.py

    diff -r c0224cfe92f4 django/core/management/commands/loaddata.py
    a b  
    33from optparse import make_option
    44import sys
    55import os
    6 import bz2, gzip, zipfile
     6import gzip, zipfile
     7
     8try:
     9    import bz2
     10except ImportError:
     11    bz2 = None
    712
    813try:
    914    set
     
    6267
    6368        compression_types = {
    6469            None:   file,
    65             'bz2':  bz2.BZ2File,
    6670            'gz':   gzip.GzipFile,
    6771            'zip':  SingleZipReader
    6872        }
     73        if bz2 is not None:
     74            compression_types['bz2'] = bz2.BZ2File
    6975
    7076        app_fixtures = [os.path.join(os.path.dirname(app.__file__), 'fixtures') for app in get_apps()]
    7177        for fixture_label in fixture_labels:
Back to Top