diff options
author | Waylan Limberg <waylan@gmail.com> | 2011-04-28 21:39:30 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2011-04-28 21:39:30 -0400 |
commit | 8c46de40ce949971c3a887f5ff9bf0da1a610d22 (patch) | |
tree | 1f356ee997e0cba8c4c8e58e65a89bc4ed61c78e | |
parent | f87713c85d8c895dc15cf78c99673efce371a056 (diff) | |
download | markdown-8c46de40ce949971c3a887f5ff9bf0da1a610d22.tar.gz markdown-8c46de40ce949971c3a887f5ff9bf0da1a610d22.tar.bz2 markdown-8c46de40ce949971c3a887f5ff9bf0da1a610d22.zip |
Restored custom error message on UnicodeDecodeError. Otherwise we will be getting bug reports all the time.
-rw-r--r-- | markdown/__init__.py | 8 |
1 files 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" |