# Buggy code
def unescape(self, text):
    """Return unescaped text given text with an inline placeholder."""
    try:
        stash = self.markdown.treeprocessors["inline"].stashed_nodes
    except KeyError:
        return text

    def get_stash(m):
        id = m.group(1)
        value = stash.get(id)
        if value is not None:
            try:
                return self.markdown.serializer(value)
            except:
                return "\%s" % value

    return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text)


# Traceback (TypeError)
In [1]: import markdown

In [2]: markdown.Markdown(safe_mode='escape').convert('<@`x`>')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-1401fbb3dfde> in <module>()
----> 1 markdown.Markdown(safe_mode='escape').convert('<@`x`>')

Python-Markdown/markdown/__init__.pyc in convert(self, source)
300         # Run the tree-processors
301         for treeprocessor in self.treeprocessors.values():
--> 302             newRoot = treeprocessor.run(root)
303             if newRoot:
304                 root = newRoot

Python-Markdown/markdown/treeprocessors.pyc in run(self, tree)
287                     child.text = None
288                     lst = self.__processPlaceholders(self.__handleInline(
--> 289                                                     text), child)
290                     stack += lst
291                     insertQueue.append((child, lst))

Python-Markdown/markdown/treeprocessors.pyc in __handleInline(self, data, patternIndex)
108                 data, matched, startIndex = self.__applyPattern(
109                     self.markdown.inlinePatterns.value_for_index(patternIndex),
--> 110                     data, patternIndex, startIndex)
111                 if not matched:
112                     patternIndex += 1

Python-Markdown/markdown/treeprocessors.pyc in __applyPattern(self, pattern, data, patternIndex, startIndex)
235             return data, False, 0
236
--> 237         node = pattern.handleMatch(match)
238
239         if node is None:

Python-Markdown/markdown/inlinepatterns.pyc in handleMatch(self, m)
436     def handleMatch(self, m):
437         el = util.etree.Element('a')
--> 438         email = self.unescape(m.group(2))
439         if email.startswith("mailto:"):
440             email = email[len("mailto:"):]

Python-Markdown/markdown/inlinepatterns.pyc in unescape(self, text)
196             if id in stash:
197                 return stash.get(id)
--> 198         return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text)
199
200

TypeError: sequence item 1: expected string or Unicode, Element found

# Fixed code
def unescape(self, text):
    """Return unescaped text given text with an inline placeholder."""
    try:
        stash = self.markdown.treeprocessors["inline"].stashed_nodes
    except KeyError:
        return text

    def get_stash(m):
        id = m.group(1)
        value = stash.get(id)
        if value is not None:
            try:
                return self.markdown.serializer(text)
            except:
                return "\%s" % value

    return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text)