Ticket #17892: resolver_repr.diff

File resolver_repr.diff, 1.1 KB (added by milosu, 3 years ago)
  • django/core/urlresolvers.py

    diff -ruN -x settings.py -x '*.pyc' -x '*.stackdump' -x '*.orig' -x '*.rej' ../Django-1.4c1.orig/django/core/urlresolvers.py ../Django-1.4c1/django/core/urlresolvers.py
    old new  
    232232        self._app_dict = {}
    233233
    234234    def __repr__(self):
    235         return smart_str(u'<%s %s (%s:%s) %s>' % (self.__class__.__name__, self.urlconf_name, self.app_name, self.namespace, self.regex.pattern))
     235        # lists can be huge and it can take a lot of time
     236        # to call __repr__ on them
     237        # use just a __class__ name instead
     238        if isinstance(self.urlconf_name, list):
     239            urlconf_name_repr = repr(self.urlconf_name.__class__)
     240        else:
     241            urlconf_name_repr = repr(self.urlconf_name)
     242        return smart_str(u'<%s %s (%s:%s) %s>' % (self.__class__.__name__, urlconf_name_repr, self.app_name, self.namespace, self.regex.pattern))
    236243
    237244    def _populate(self):
    238245        lookups = MultiValueDict()
Back to Top