python3异步数据处理

2024-05-26 07:47:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用asynchat并尝试使用python3。获取此错误:

    error: uncaptured python exception, closing channel <irc.IRC connected
    at 0x9a5286c> (<class 'AttributeError'>:'str' object has no attribute 
    'more' [/usr/lib/python3.2/asyncore.py|write|89] [/usr/lib/python3.2
    /asyncore.py|handle_write_event|462] [/usr/lib/python3.2asynchat.py|
    handle_write|194] [/usr/lib/python3.2/asynchat.py|initiate_send|245])

我的代码在python2.6.7中运行良好。在

请提出建议?在

更新:我检查过我确实在使用python3的asynchat。在

^{pr2}$

Tags: pylibusrirc错误exceptionchannelerror
2条回答

http://bugs.python.org/issue12523

Actually, the error is that in Python 3 you should use bytes objects when transmitting/receiving data over the network, not (unicode) strings. That is, replace '\r\n' with b'\r\n', etc.

Of course, the error message should be made less obscure.

错误似乎在/usr/lib/python3.2/asynchat.py|initiate_send|245中引发。在

def initiate_send(self):
    while self.producer_fifo and self.connected:
        first = self.producer_fifo[0]
        ...
        try:
            data = buffer(first, 0, obs)
        except TypeError:
            data = first.more() < - here 

好像有人在self.producer_fifo中放了一个字符串,而不是asyncchat.simple_producer,这是{}中唯一使用more()方法的类。在

相关问题 更多 >