Django

Code

Ticket #5743: ticket_5743__rev_6819.diff

File ticket_5743__rev_6819.diff, 3.8 kB (added by __hawkeye__, 7 months ago)

Fixed typo

  • django/conf/__init__.py

    old new  
    5252            if not settings_module: # If it's set but is an empty string. 
    5353                raise KeyError 
    5454        except KeyError: 
    55             raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE 
     55            raise ImportError, "Environment variable %s is undefined so settings cannot be imported." % ENVIRONMENT_VARIABLE   # NOTE: This is arguably an EnvironmentError, but that causes problems with Python's interactive help 
    5656 
    5757        self._target = Settings(settings_module) 
    5858 
     
    6363        argument must support attribute access (__getattr__)). 
    6464        """ 
    6565        if self._target != None: 
    66             raise EnvironmentError, 'Settings already configured.' 
     66            raise RuntimeError, 'Settings already configured.' 
    6767        holder = UserSettingsHolder(default_settings) 
    6868        for name, value in options.items(): 
    6969            setattr(holder, name, value) 
     
    8282        try: 
    8383            mod = __import__(self.SETTINGS_MODULE, {}, {}, ['']) 
    8484        except ImportError, e: 
    85             raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) 
     85            raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) 
    8686 
    8787        # Settings that should be converted into tuples if they're mistakenly entered 
    8888        # as strings. 
  • django/core/management/__init__.py

    old new  
    8484        try: 
    8585            from django.conf import settings 
    8686            apps = settings.INSTALLED_APPS 
    87         except (AttributeError, EnvironmentError): 
     87        except (AttributeError, ImportError): 
    8888            apps = [] 
    8989 
    9090        for app_name in apps: 
     
    9999        try: 
    100100            from django.conf import settings 
    101101            project_directory = setup_environ(__import__(settings.SETTINGS_MODULE)) 
    102         except (AttributeError, EnvironmentError, ImportError): 
     102        except (AttributeError, ImportError): 
    103103            project_directory = None 
    104104 
    105105        if project_directory: 
  • django/newforms/fields.py

    old new  
    409409try: 
    410410    from django.conf import settings 
    411411    URL_VALIDATOR_USER_AGENT = settings.URL_VALIDATOR_USER_AGENT 
    412 except (ImportError, EnvironmentError)
     412except ImportError
    413413    # It's OK if Django settings aren't configured. 
    414414    URL_VALIDATOR_USER_AGENT = 'Django (http://www.djangoproject.com/)' 
    415415 
  • docs/settings.txt

    old new  
    11661166settings. 
    11671167 
    11681168If you don't set ``DJANGO_SETTINGS_MODULE`` and don't call ``configure()``, 
    1169 Django will raise an ``EnvironmentError`` exception the first time a setting 
    1170 is accessed. 
     1169Django will raise an ``ImportError`` exception the first time a setting 
     1170is accessed. 
    11711171 
    11721172If you set ``DJANGO_SETTINGS_MODULE``, access settings values somehow, *then* 
    1173 call ``configure()``, Django will raise an ``EnvironmentError`` saying settings 
    1174 have already been configured. 
     1173call ``configure()``, Django will raise a ``RuntimeError`` indicating 
     1174that settings have already been configured. 
    11751175 
    11761176Also, it's an error to call ``configure()`` more than once, or to call 
    11771177``configure()`` after any setting has been accessed.