def stanza_error(self, elem, kind, condition, text=None):
        """Write a stanza-level error to the stream.

        <stanza-kind to='sender' type='error'>
          [RECOMMENDED to include sender XML here]
          <error type='error-type'>
            <defined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
            <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'
                  xml:lang='langcode'>
              OPTIONAL descriptive text
            </text>
            [OPTIONAL application-specific condition element]
          </error>
        </stanza-kind>
        """
        error = self.E.error(type=kind)
        error.append(self.E(condition, { 'xmlns': self.STANZAS }))
        if text:
            error.append(self.E.text({ 'xmlns': self.STANZAS }, text))

        reply_info = {
#            'from': unicode(self.serverJID),
            'type': 'error',
            'id': elem.get('id')
        }
        if (elem.get('to') != None):
            reply_info['from'] = elem.get('to')
        stanza = self.E(elem.tag, reply_info)
        if 0 > len(elem):
            stanza.append(elem[0])
        stanza.append(error)

        return self.write(stanza)

    ### ---------- Features ----------
dataset/ETHPy150Open HenryHu/pybbs/xmpp/core.py/Core.stanza_error/swapped operands of `>`