List Info

Thread: Wrong assertion in __init__ of ValidationError?




Wrong assertion in __init__ of ValidationError?
country flaguser name
United States
2007-07-29 02:42:08
This is from django r5773:

class ValidationError(Exception):
    def __init__(self, message):
        "ValidationError can be passed a string or a
list."
        if isinstance(message, list):
            self.messages = ErrorList([smart_unicode(msg)
for msg in
message])
        else:
            assert isinstance(message, basestring),
("%s should be a
basestring" % repr(message))
            message = smart_unicode(message)
            self.messages = ErrorList([message])

    def __str__(self):
        # This is needed because, without a __str__(),
printing an
exception
        # instance would result in this:
        # AttributeError: ValidationError instance has no
attribute
'args'
        # See http://www.python.org/doc/current/tut/node10.html#hand
ling
        return repr(self.messages)


I don't understand the line:
assert isinstance(message, basestring), ("%s should be
a basestring" %
repr(message))

I think it should be OK if message is an instance of
Promise. And
usually the message IS instance of Promise if using i18n.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Wrong assertion in __init__ of ValidationError?
user name
2007-07-30 09:07:13
Hi Gilbert --

Yeah, this is a bug; it's on my shortlist to fix.

Jacob

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )