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

cannot connect: no attribute '_auth_plugin_name' #86

Open
t184256 opened this issue Feb 16, 2024 · 3 comments · May be fixed by #87
Open

cannot connect: no attribute '_auth_plugin_name' #86

t184256 opened this issue Feb 16, 2024 · 3 comments · May be fixed by #87

Comments

@t184256
Copy link

t184256 commented Feb 16, 2024

Cannot use asyncmy to connect to a specific server, while aiomysql works.

$ /usr/bin/python3 -m asyncio
...
>>> import aiomysql
>>> c = await aiomysql.connect(...)  # works fine
>>> import asyncmy
>>> c = await asyncmy.connect(...)
Traceback (most recent call last):
  File "/usr/lib64/python3.12/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "<console>", line 1, in <module>
  File "asyncmy/connection.pyx", line 1343, in _connect
  File "asyncmy/connection.pyx", line 594, in connect
  File "asyncmy/connection.pyx", line 572, in asyncmy.connection.Connection.connect
  File "asyncmy/connection.pyx", line 787, in _request_authentication
AttributeError: 'Connection' object has no attribute '_auth_plugin_name'. Did you mean: '_auth_plugin_map'?

Code inspection suggests that _request_authentication uses _auth_plugin_name unconditionally:

if self._auth_plugin_name == "":

... while it's only set if a certain condition is met:

if self.server_capabilities & PLUGIN_AUTH and len(data) >= i:

Should it have some default pre-set?

Version: python3-asyncmy-0.2.9-1.fc39.x86_64
Server reports itself as MariaDB, Server version: 5.1.73-log Source distribution.

@long2ice
Copy link
Owner

Thanks for report! Could you make a PR?

@t184256
Copy link
Author

t184256 commented Feb 16, 2024

I don't know what the default should be.

t184256 added a commit to t184256/asyncmy that referenced this issue Feb 16, 2024
... in case it doesn't get set later.

Fixes: long2ice#86
@t184256
Copy link
Author

t184256 commented Feb 16, 2024

Hm, I've checked aiomysql (https://github.com/aio-libs/aiomysql/blob/83aa96e12b1b3f2bd373f60a9c585b6e73f40f52/aiomysql/connection.py#L218) and it uses "" as a default. I've tried setting it to "" and it seems to solve it for me. I don't see how "" could be worse than an absence of the attribute, so I'll file a PR.

@t184256 t184256 linked a pull request Feb 16, 2024 that will close this issue
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 a pull request may close this issue.

2 participants