fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

ValueError: unknown event b'end' (PyPy 3.2) #314

Open mdevaev opened 10 years ago

mdevaev commented 10 years ago

Simple code:

import sleekxmpp
import logging

logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s')

client = sleekxmpp.ClientXMPP("from@example.com", "secret")
def send(_):
    client.send_message(mto="to@example.com", mbody="Oh hi!", mtype="chat")
    client.disconnect(wait=True)
client.add_event_handler("session_start", send)
if client.connect(reattempt=False):
    client.process(block=True)

When running on PyPy (Python 3.2) causes an error:

$ pypy3 foo.py 
...
DEBUG     ==== TRANSITION disconnected -> connected
DEBUG    SEND (IMMED): <stream:stream to='im.etersoft.ru' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
ERROR    unknown event b'end'
Traceback (most recent call last):
  File "/home/mdevaev/.local/lib/python3.2/site-packages/sleekxmpp-1.3.1-py3.2.egg/sleekxmpp/xmlstream/xmlstream.py", line 1481, in _process
    if not self.__read_xml():
  File "/home/mdevaev/.local/lib/python3.2/site-packages/sleekxmpp-1.3.1-py3.2.egg/sleekxmpp/xmlstream/xmlstream.py", line 1523, in __read_xml
    for event, xml in ET.iterparse(self.filesocket, (b'end', b'start')):
  File "/opt/pypy3/lib-python/3/xml/etree/ElementTree.py", line 1242, in iterparse
    return _IterParseIterator(source, events, parser, close_source)
  File "/opt/pypy3/lib-python/3/xml/etree/ElementTree.py", line 1287, in __init__
    raise ValueError("unknown event %r" % event)
ValueError: unknown event b'end'
DEBUG    reconnecting...
DEBUG    Event triggered: session_end
DEBUG    SEND (IMMED): </stream:stream>
INFO     Waiting for </stream:stream> from server
DEBUG    Event triggered: disconnected
DEBUG     ==== TRANSITION connected -> disconnected
...

No messages. On pure python 3.2 working fine.

bear commented 9 years ago

I just ran this against my Prosody server and it works using Python v3.4, if it still fails let me know what server your trying against

... removed startup lines DEBUG ==== TRANSITION disconnected -> connected DEBUG Starting HANDLER THREAD DEBUG Loading event runner DEBUG SEND (IMMED): DEBUG RECV: DEBUG RECV: /stream:features DEBUG SEND (IMMED): DEBUG RECV: DEBUG Starting TLS INFO Negotiating TLS INFO Using SSL version: TLS 1.0 DEBUG Event triggered: ssl_cert

... removed cert debug lines

DEBUG SEND (IMMED): DEBUG RECV:

mdevaev commented 9 years ago

It fails on PyPy 3.2, not on usual Python.

bear commented 9 years ago

I'll get v3.2 installed and try again - thanks

mdevaev commented 9 years ago

The server - jabber.ru