-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Wrong constructor called #8059
Comments
Does this result in some wrong behaviour (like the error message being incorrect)? If so, then a simple test would be great. |
Yes there is one wrong behavior: the OSError object is not properly initialized with the errno information. So any user of the library catching OSErrors will obtain wrongly initialized objects. This is an exotic case although. I didn't focus on the error message as aiohttp is (like many Python libraries) very heterogeneous in terms of quality of the exception messages, from none (no message at all despite useful information available) to very chatty. So I don't think the error message is the issue there (and if it were it would require a separate issue to resolve it across several exception types). |
That's fine, if you can add a test showing that, then feel free to make a fix. |
@dmoklaf It looks like it is working as expected to me. You can dump the order in which python runs init methods via this:
which gives:
Because none of the intermediate Client*Error classes define their own init method the next interesting one to be called is OSError You can also see it working via a test case like this:
which will print out these values (assuming that text file does not exist)
|
Describe the bug
The
ClientConnectorError
class has 2 grand-parent classes:ClientConnectionError
andOSError
, in that order.However, it seems to call the constructor of the wrong grand-parent:
aiohttp/aiohttp/client_exceptions.py
Line 136 in a379e63
Following the Python language specification ,a default super() calls the constructor of the first grand parent class,
ClientConnectionError
, with the wrong arguments (the constructor is supposed to take a message as first argument). The arguments provided,os_error.errno,
and, os_error.strerror
suggest that it should call instead the constructor of the second grand parent class,OSError
.But maybe my understanding of these classes is wrong.
To Reproduce
Read the code of the client_exceptions.py file:
aiohttp/aiohttp/client_exceptions.py
Line 136 in a379e63
Expected behavior
If my theory is true, then the constructor of the second grand-parent class shall be called, through:
super(OSError, self).__init__(os_error.errno, os_error.strerror)
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
MacOS Sonoma 14.2.1 (23C71)
Related component
Client
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: