1

私は 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])

私のコードは Python 2.6.7 で問題なく動作しました。

提案してください?

更新:実際に python3 の asynchat を使用していることを確認しました。

    ~$ python3
    Python 3.2 (r32:88445, Mar 25 2011, 19:28:28) 
    [GCC 4.5.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import asynchat
    >>> asynchat
    <module 'asynchat' from '/usr/lib/python3.2/asynchat.py'>
    >>> 
4

2 に答える 2

3

http://bugs.python.org/issue12523による

実際、エラーは、Python 3 では、(unicode) 文字列ではなく、ネットワーク経由でデータを送受信するときにバイト オブジェクトを使用する必要があることです。つまり、'\r\n' を b'\r\n' などに置き換えます。

もちろん、エラー メッセージはもっとわかりにくくする必要があります。

于 2011-12-29T04:43:36.697 に答える
1

でエラーが発生したよう/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_producerasync*.pymore()

于 2011-07-09T11:09:49.117 に答える