# Path: pyxmpp/exceptions.py
# class StreamParseError(FatalStreamError):
#     """Raised when invalid XML is received in an XMPP stream."""
#     pass


import sys
import libxml2
import threading
import re
import logging
from pyxmpp.exceptions import StreamParseError
    from pyxmpp import _xmlextra
    from pyxmpp._xmlextra import error
            - `handler`: handler object for the stream content
        :Types:
            - `handler`: `StreamHandler` derived class
        """
        self.reader=_create_reader(handler)
        self.lock=threading.RLock()
        self.in_use=0
    def doc(self):
        """Get the document being parsed.

        :return: the document.
        :returntype: `libxml2.xmlNode`"""
        ret=self.reader.doc()
        if ret:
            return libxml2.xmlDoc(ret)
        else:
            return None
    def feed(self,s):
        """Pass a string to the stream parser.

        Parameters:
            - `s`: string to parse.
        Types:
            - `s`: `str`

        :return: `None` on EOF, `False` when whole input was parsed and `True`
            if there is something still left in the buffer."""
        self.lock.acquire()
        if self.in_use:
            self.lock.release()

# Path: pyxmpp/exceptions.py
# class StreamParseError(FatalStreamError):
#     """Raised when invalid XML is received in an XMPP stream."""
#     pass


# Path: pyxmpp/xmlextra.py
import sys
import libxml2
import threading
import re
import logging
from pyxmpp.exceptions import StreamParseError
    from pyxmpp import _xmlextra
    from pyxmpp._xmlextra import error

            - `handler`: handler object for the stream content
        :Types:
            - `handler`: `StreamHandler` derived class
        """
        self.reader=_create_reader(handler)
        self.lock=threading.RLock()
        self.in_use=0
    def doc(self):
        """Get the document being parsed.

        :return: the document.
        :returntype: `libxml2.xmlNode`"""
        ret=self.reader.doc()
        if ret:
            return libxml2.xmlDoc(ret)
        else:
            return None
    def feed(self,s):
        """Pass a string to the stream parser.

        Parameters:
            - `s`: string to parse.
        Types:
            - `s`: `str`

        :return: `None` on EOF, `False` when whole input was parsed and `True`
            if there is something still left in the buffer."""
        self.lock.acquire()
        if self.in_use:
            self.lock.release()

            raise StreamParseError,"StreamReader.feed() is not reentrant!"