#10354: encoding.force_unicode exception unclear/vague, update to clarify exception -------------------------------------+-------------------------------------- Reporter: monkut | Owner: nobody Status: reopened | Milestone: Component: Core framework | Version: 1.0 Resolution: | Keywords: exception-clarification Stage: Unreviewed | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | -------------------------------------+-------------------------------------- Changes (by monkut):
* status: closed => reopened * has_patch: 0 => 1 * resolution: wontfix => Comment: Replying to [comment:1 jacob]: Good point. My concern is that new users of django like myself may get turned off of the framework due to confusing exceptions like this one. Just to clarify your point, your saying that there is an issue if in the body of the __unicode__ method of 's' a TypeError is raised, right? The issue I see is that the 'real' problem is hidden from the user because the exception points to force_unicode(), making it difficult to quickly debug the problem. It would be nice if the developer could be pointed a little closer to the 'real' problem. How about changing the message and re-raising the original exception? {{{ def force_unicode(s, encoding='utf-8', strings_only=False, errors='strict'): ... if strings_only and isinstance(s, (types.NoneType, int, long, datetime.datetime, datetime.date, datetime.time, float)): return s try: if not isinstance(s, basestring,): if hasattr(s, '__unicode__'): try: s = unicode(s) except TypeError, e: msg = u"Found in %s's __unicode__ method" % (repr(type(s))) mutable_args = list(e.args) mutable_args.append(msg) e.args = tuple(mutable_args) raise e }}} -- Ticket URL: <http://code.djangoproject.com/ticket/10354#comment:2> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---