From 8c46de40ce949971c3a887f5ff9bf0da1a610d22 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 28 Apr 2011 21:39:30 -0400 Subject: Restored custom error message on UnicodeDecodeError. Otherwise we will be getting bug reports all the time. --- markdown/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/markdown/__init__.py b/markdown/__init__.py index 0ca0509..2bc7061 100644 --- a/markdown/__init__.py +++ b/markdown/__init__.py @@ -243,8 +243,12 @@ class Markdown: if not source.strip(): return u"" # a blank unicode string - # if this raises UnicodeDecodeError, that's the caller's fault. - source = unicode(source) + try: + source = unicode(source) + except UnicodeDecodeError, e: + # Customise error message while maintaining original trackback + e.reason += '. -- Note: Markdown only accepts unicode input!' + raise source = source.replace(util.STX, "").replace(util.ETX, "") source = source.replace("\r\n", "\n").replace("\r", "\n") + "\n\n" -- cgit v1.2.3