pyrofork icon indicating copy to clipboard operation
pyrofork copied to clipboard

can't print story

Open gmankab opened this issue 8 months ago • 0 comments

Checklist

  • [X] I am sure the error is coming from Pyrofork's code and not elsewhere
  • [X] I have searched in the issue tracker for similar bug reports, including closed ones
  • [X] I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

see code example

Steps to reproduce

see code example

Code example

import pyrogram.client
import pyrogram.types
import asyncio


async def main():
    client = pyrogram.client.Client(
        name='tg_bot',
    )
    await client.start()
    msg = await client.get_messages(
        chat_id='@autotests_source',
        message_ids=121,
    )
    assert isinstance(msg, pyrogram.types.Message)
    print(msg.story.__dict__) # works
    print(msg.story) # throws error


asyncio.run(main())

Logs

.venv/bin/python test.py
Traceback (most recent call last):
  File "/var/home/hmk/proj/test/test.py", line 20, in <module>
    asyncio.run(main())
  File "/usr/lib64/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/var/home/hmk/proj/test/test.py", line 17, in main
    print(msg.story)
  File "/var/home/hmk/proj/test/.venv/lib64/python3.12/site-packages/pyrogram/types/object.py", line 83, in __str__
    return dumps(self, indent=4, default=Object.default, ensure_ascii=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/encoder.py", line 202, in encode
    chunks = list(chunks)
             ^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/encoder.py", line 440, in _iterencode
    yield from _iterencode(o, _current_indent_level)
  File "/usr/lib64/python3.12/json/encoder.py", line 432, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib64/python3.12/json/encoder.py", line 406, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.12/json/encoder.py", line 439, in _iterencode
    o = _default(o)
        ^^^^^^^^^^^
  File "/var/home/hmk/proj/test/.venv/lib64/python3.12/site-packages/pyrogram/types/object.py", line 72, in default
    obj.__dict__,
    ^^^^^^^^^^^^
AttributeError: 'Chats' object has no attribute '__dict__'. Did you mean: '__dir__'?

gmankab avatar Jun 15 '24 04:06 gmankab