Skip to content

登录后出现 TypeError: issubclass() arg 1 must be a class 异常 #54

@WindowsSov8forUs

Description

@WindowsSov8forUs

扫码登录成功后出现如下异常追栈信息:

Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code

  File "D:\anon\nekobox\.venv\Scripts\nekobox.exe\__main__.py", line 7, in <module>

  File "D:\anon\nekobox\.venv\Lib\site-packages\nekobox\__main__.py", line 308, in main
    if args.func(args):
       │    │    └ Namespace(command='run', uin=None, debug=False, use_png=False, func=<function _run at 0x0000024C928B99E0>)
       │    └ <function _run at 0x0000024C928B99E0>
       └ Namespace(command='run', uin=None, debug=False, use_png=False, func=<function _run at 0x0000024C928B99E0>)
  File "D:\anon\nekobox\.venv\Lib\site-packages\nekobox\__main__.py", line 188, in _run
    run(int(uin), host, port, token, path, protocol, sign_url, level, args.use_png)
    │       │     │     │     │      │     │         │         │      │    └ False
    │       │     │     │     │      │     │         │         │      └ Namespace(command='run', uin=None, debug=False, use_png=False, func=<function _run at 0x0000024C928B99E0>)
    │       │     │     │     │      │     │         │         └ 'INFO'
    │       │     │     │     │      │     │         └ 'https://sign.lagrangecore.org/api/sign/30366'
    │       │     │     │     │      │     └ 'remote'
    │       │     │     │     │      └ ''
    │       │     │     │     └ 'AnonChihaya'
    │       │     │     └ 60000
    │       │     └ '127.0.0.1'
    │       └ '1953421488'<function run at 0x0000024C8ED12E80>
  File "D:\anon\nekobox\.venv\Lib\site-packages\nekobox\__main__.py", line 38, in run
    server.run()
    │      └ <function Server.run at 0x0000024C9283ED40><satori.server.Server object at 0x0000024C910D4440>
  File "D:\anon\nekobox\.venv\Lib\site-packages\satori\server\__init__.py", line 471, in run
    manager.launch_blocking(loop=loop, stop_signal=stop_signal)
    │       │                    │                 └ (<Signals.SIGINT: 2>,)
    │       │                    └ None
    │       └ <function Launart.launch_blocking at 0x0000024C92483EC0><launart.manager.Launart object at 0x0000024C928BD940>
  File "D:\anon\nekobox\.venv\Lib\site-packages\launart\manager.py", line 468, in launch_blocking
    loop.run_until_complete(launch_task)
    │    │                  └ <Task pending name='amnesia-launch' coro=<Launart.launch() running at D:\anon\nekobox\.venv\Lib\site-packages\launart\manager...
    │    └ <function BaseEventLoop.run_until_complete at 0x0000024C90AB6160><ProactorEventLoop running=True closed=False debug=False>
  File "C:\Users\WindowsSov8\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 712, in run_until_complete
    self.run_forever()
    │    └ <function BaseEventLoop.run_forever at 0x0000024C90AB60C0><ProactorEventLoop running=True closed=False debug=False>
  File "C:\Users\WindowsSov8\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 683, in run_forever
    self._run_once()
    │    └ <function BaseEventLoop._run_once at 0x0000024C90AB7EC0><ProactorEventLoop running=True closed=False debug=False>
  File "C:\Users\WindowsSov8\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 2040, in _run_once
    handle._run()
    │      └ <function Handle._run at 0x0000024C9091E700><Handle Task.task_wakeup()>
  File "C:\Users\WindowsSov8\AppData\Local\Programs\Python\Python313\Lib\asyncio\events.py", line 89, in _run
    self._context.run(self._callback, *self._args)
    │    │            │    │           │    └ <member '_args' of 'Handle' objects>
    │    │            │    │           └ <Handle Task.task_wakeup()>
    │    │            │    └ <member '_callback' of 'Handle' objects>
    │    │            └ <Handle Task.task_wakeup()>
    │    └ <member '_context' of 'Handle' objects><Handle Task.task_wakeup()>
> File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\client\base.py", line 148, in _push_handle_loop
    await self.push_handler(sso)
          │    │            └ SSOPacket(seq=-1321044337, ret_code=0, extra='', session_id=b'', cmd='trpc.msg.olpush.OlPushService.MsgPush', data=b'\n\x92\x...
          │    └ <function Client.push_handler at 0x0000024C91382D40>
          └ <lagrange.client.client.Client object at 0x0000024C92933A10>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\client\client.py", line 185, in push_handler
    if rsp := await self._push_deliver.execute(sso.cmd, sso):
                    │    │             │       │   │    └ SSOPacket(seq=-1321044337, ret_code=0, extra='', session_id=b'', cmd='trpc.msg.olpush.OlPushService.MsgPush', data=b'\n\x92\x...
                    │    │             │       │   └ 'trpc.msg.olpush.OlPushService.MsgPush'
                    │    │             │       └ SSOPacket(seq=-1321044337, ret_code=0, extra='', session_id=b'', cmd='trpc.msg.olpush.OlPushService.MsgPush', data=b'\n\x92\x...
                    │    │             └ <function PushDeliver.execute at 0x0000024C91382160>
                    │    └ <lagrange.client.server_push.binder.PushDeliver object at 0x0000024C92A20050>
                    └ <lagrange.client.client.Client object at 0x0000024C92933A10>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\client\server_push\binder.py", line 26, in execute
    return await self._handle_map[cmd](self._client, sso)
                 │    │           │    │    │        └ SSOPacket(seq=-1321044337, ret_code=0, extra='', session_id=b'', cmd='trpc.msg.olpush.OlPushService.MsgPush', data=b'\n\x92\x...
                 │    │           │    │    └ <lagrange.client.client.Client object at 0x0000024C92933A10>
                 │    │           │    └ <lagrange.client.server_push.binder.PushDeliver object at 0x0000024C92A20050>
                 │    │           └ 'trpc.msg.olpush.OlPushService.MsgPush'
                 │    └ {'trpc.msg.olpush.OlPushService.MsgPush': <function msg_push_handler at 0x0000024C91382480>, 'trpc.qq_new_tech.status_svc.Sta...
                 └ <lagrange.client.server_push.binder.PushDeliver object at 0x0000024C92A20050>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\client\server_push\msg.py", line 77, in msg_push_handler
    pkg = MsgPush.decode(sso.data).body
          │       │      │   └ b'\n\x92\x03\n\x7f\x08\xf7\xef\x9d\xe7\n\x12\x18u_KMAqMhSn-QG9Khx1Riklvw\x18\xe9\x07 \xbd\xaa\x99\x80\x02(\xb0\xb1\xbb\xa3\x0...
          │       │      └ SSOPacket(seq=-1321044337, ret_code=0, extra='', session_id=b'', cmd='trpc.msg.olpush.OlPushService.MsgPush', data=b'\n\x92\x...
          │       └ <classmethod(<function ProtoStruct.decode at 0x0000024C9119C900>)>
          └ <class 'lagrange.pb.message.msg_push.MsgPush'>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 294, in decode
    return cls(True, **kwargs)
           │           └ {'body': b'\n\x7f\x08\xf7\xef\x9d\xe7\n\x12\x18u_KMAqMhSn-QG9Khx1Riklvw\x18\xe9\x07 \xbd\xaa\x99\x80\x02(\xb0\xb1\xbb\xa3\x07...
           └ <class 'lagrange.pb.message.msg_push.MsgPush'>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 185, in __init__
    value = _decode(field.type_without_optional, value)
            │       │     │                      └ b'\n\x7f\x08\xf7\xef\x9d\xe7\n\x12\x18u_KMAqMhSn-QG9Khx1Riklvw\x18\xe9\x07 \xbd\xaa\x99\x80\x02(\xb0\xb1\xbb\xa3\x07BN\x08\x9...
            │       │     └ <property object at 0x0000024C9118A7F0>
            │       └ <lagrange.utils.binary.protobuf.models.ProtoField object at 0x0000024C911BF4D0>
            └ <function _decode at 0x0000024C9119C2C0>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 120, in _decode
    return typ.decode(raw)
           │   │      └ b'\n\x7f\x08\xf7\xef\x9d\xe7\n\x12\x18u_KMAqMhSn-QG9Khx1Riklvw\x18\xe9\x07 \xbd\xaa\x99\x80\x02(\xb0\xb1\xbb\xa3\x07BN\x08\x9...
           │   └ <classmethod(<function ProtoStruct.decode at 0x0000024C9119C900>)><class 'lagrange.pb.message.msg_push.MsgPushBody'>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 294, in decode
    return cls(True, **kwargs)
           │           └ {'response_head': b'\x08\xf7\xef\x9d\xe7\n\x12\x18u_KMAqMhSn-QG9Khx1Riklvw\x18\xe9\x07 \xbd\xaa\x99\x80\x02(\xb0\xb1\xbb\xa3\...
           └ <class 'lagrange.pb.message.msg_push.MsgPushBody'>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 185, in __init__
    value = _decode(field.type_without_optional, value)
            │       │     │                      └ b'\n\xe3\x01\n!\x08\x00\x10\x93\xd2\x95\xc1\x06\x18\xf3\x86\xf7\xc6\x01 \x00(\n0\x008\x86\x01@\x02J\x06\xe5\xae\x8b\xe4\xbd\x...
            │       │     └ <property object at 0x0000024C9118A7F0>
            │       └ <lagrange.utils.binary.protobuf.models.ProtoField object at 0x0000024C911BF350><function _decode at 0x0000024C9119C2C0>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 120, in _decode
    return typ.decode(raw)
           │   │      └ b'\n\xe3\x01\n!\x08\x00\x10\x93\xd2\x95\xc1\x06\x18\xf3\x86\xf7\xc6\x01 \x00(\n0\x008\x86\x01@\x02J\x06\xe5\xae\x8b\xe4\xbd\x...
           │   └ <classmethod(<function ProtoStruct.decode at 0x0000024C9119C900>)>
           └ <class 'lagrange.pb.message.msg.Message'>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 294, in decode
    return cls(True, **kwargs)
           │           └ {'body': b'\n!\x08\x00\x10\x93\xd2\x95\xc1\x06\x18\xf3\x86\xf7\xc6\x01 \x00(\n0\x008\x86\x01@\x02J\x06\xe5\xae\x8b\xe4\xbd\x9...
           └ <class 'lagrange.pb.message.msg.Message'>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 185, in __init__
    value = _decode(field.type_without_optional, value)
            │       │     │                      └ b'\n!\x08\x00\x10\x93\xd2\x95\xc1\x06\x18\xf3\x86\xf7\xc6\x01 \x00(\n0\x008\x86\x01@\x02J\x06\xe5\xae\x8b\xe4\xbd\x93\x12x\xa...
            │       │     └ <property object at 0x0000024C9118A7F0>
            │       └ <lagrange.utils.binary.protobuf.models.ProtoField object at 0x0000024C911733D0>
            └ <function _decode at 0x0000024C9119C2C0>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 120, in _decode
    return typ.decode(raw)
           │   │      └ b'\n!\x08\x00\x10\x93\xd2\x95\xc1\x06\x18\xf3\x86\xf7\xc6\x01 \x00(\n0\x008\x86\x01@\x02J\x06\xe5\xae\x8b\xe4\xbd\x93\x12x\xa...
           │   └ <classmethod(<function ProtoStruct.decode at 0x0000024C9119C900>)><class 'lagrange.pb.message.rich_text.RichText'>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 294, in decode
    return cls(True, **kwargs)
           │           └ {'attrs': b'\x08\x00\x10\x93\xd2\x95\xc1\x06\x18\xf3\x86\xf7\xc6\x01 \x00(\n0\x008\x86\x01@\x02J\x06\xe5\xae\x8b\xe4\xbd\x93'...
           └ <class 'lagrange.pb.message.rich_text.RichText'>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 185, in __init__
    value = _decode(field.type_without_optional, value)
            │       │     │                      └ [b'\xaa\x02u\x08\x00P\x00`\x00h\x00\x80\x01\x00\x88\x01\xb0\xa0\t\x9a\x01b\x08\x08x\x80\x80\x04\xc8\x01\x00\xf0\x01\x00\xf8\x...
            │       │     └ <property object at 0x0000024C9118A7F0>
            │       └ <lagrange.utils.binary.protobuf.models.ProtoField object at 0x0000024C911BEED0>
            └ <function _decode at 0x0000024C9119C2C0>
  File "D:\anon\nekobox\.venv\Lib\site-packages\lagrange\utils\binary\protobuf\models.py", line 119, in _decode
    if issubclass(typ, ProtoStruct):
                  │    └ <class 'lagrange.utils.binary.protobuf.models.ProtoStruct'>
                  └ list[lagrange.pb.message.rich_text.Elems]

TypeError: issubclass() arg 1 must be a class

询问 claude-3.7-sonnet 后,认为问题出现在 lagrange/utils/binary/protobuf/models.py 的如下函数中:

def _decode(typ: type[_ProtoTypes], raw):
    if isinstance(typ, str):
        raise ValueError(
            f"ForwardRef '{typ}' not resolved. "
            f"Please call ProtoStruct.update_forwardref({{'{typ}': {typ}}}) before decoding"
        )
    if issubclass(typ, ProtoStruct):
        return typ.decode(raw)
    ...

抛出异常时,此处 typ 类型为 list[lagrange.pb.message.rich_text.Elems] ,无法作为 issubclass 方法的第一个参数传入。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions