Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug on baseclient.py #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

DonLarry
Copy link

@DonLarry DonLarry commented Jun 14, 2024

Line 55 says:

loop.set_exception_handler(err_handler)

If loop is None and handler is not None when the class constructor is called, then:

  1. loop remains None at line 55, and we will get an AttributeError saying that NoneType has no attribute set_exception_handler.
  2. self.loop will be updated when update_event_loop method is invoked at line 31.

So, we should use self.loop or assign self.loop to loop before using it.

If `loop` is None at line 55, it remains None because it wasn't modified earlier.

The `self.loop` was updated when `update_event_loop` function was invoked at line 31.

So, we should use `self.loop` or assign `self.loop` to `loop` before using it.
@NikOverflow
Copy link
Collaborator

Line 55 says:

loop.set_exception_handler(err_handler)

If loop is None and handler is not None when the class constructor is called, then:

  1. loop remains None at line 55, and we will get an AttributeError saying that NoneType has no attribute set_exception_handler.
  2. self.loop will be updated when update_event_loop method is invoked at line 31.

So, we should use self.loop or assign self.loop to loop before using it.

Do you have a proof of concept that calls the exception?

@NikOverflow NikOverflow added the question Further information is requested label Jun 14, 2024
@DonLarry
Copy link
Author

DonLarry commented Jun 14, 2024

Do you have a proof of concept that calls the exception?

Yes, I do. Try to run this simple code for example:

from pypresence import Presence

def f(a, b):
    pass

Presence(client_id=123, handler=f)

I'm getting the following error:

Traceback (most recent call last):
  File "...\a.py", line 6, in <module>
    Presence(client_id=123, handler=f)
  File "...\venv\Lib\site-packages\pypresence\presence.py", line 13, in __init__
    super().__init__(*args, **kwargs)
  File "...\venv\Lib\site-packages\pypresence\baseclient.py", line 55, in __init__
    loop.set_exception_handler(err_handler)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'set_exception_handler'

@NikOverflow NikOverflow removed the question Further information is requested label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants