-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
exceptions raised without a type (breaks Python2 compatibility) #58
Comments
Have you seen the Python 3 documentation for From that page:
I'm not sure I understand how you've got that error from the code you pointed at. The |
Agreed that Python3 is fine with it. The issue is that Python2 does not handle it well. |
Can't reproduce on Py2.7 either:
|
I just confirmed that it works as you just described in Python 2.7.12. So now I'm confused too. Maybe older minor versions of Python 2.7 don't behave this way? EDIT: To be clear, I never got the error myself. A user of my tool got the error, and I'm trying to resolve it on their behalf. See cs01/gdbgui#144 for his screenshot. |
Though we don't understand why the error is occurring, it seems like it wouldn't hurt to always explicitly raise an exception. Would you be open to making that change? I can submit a pull request if you are. |
The problem is that I don't just want to raise an exception. I want to raise the exception that I just caught. If I raise a different exception I would be losing the context of where the original exception occurred. That's the whole point of using Does your user have a way to reproduce this? |
I'm not sure, I just asked him. I will let you know if/when he responds. |
@cs01 I think I may have figured out this problem. Seems to be an issue with Python 2.7 when multiple exceptions are raised. I extended my division by zero example above as follows:
This was Python 3. But Python 2 appears to get confused by the inner exception:
This demonstrates that any exceptions raised during the handling of another exception can mess up the exception stack, even if they are handled properly. Not completely sure how we get from this to the problem you reported, but clearly there is something going on with Python 2 that isn't expected. I have to figure out a way to re-raise these exceptions in a way that is compatible with both Python 2 and 3. Hopefully |
@cs01 I have put a fix that I hope will solve the problem you reported. Would your user be able to install this package from git master and confirm? |
Thanks! Currently they install via pip, which pulls in engineio as a dependency. Do you have a recommended installation procedure/command I can recommend they follow to test this? I'm pretty sure your fix will work since you seem to have identified the root cause and have tested the fix. In any case it will at least improve the situation. I would be fine if you released a new version and I updated my dependencies in setup.py, but of course it's up to you. |
Problem is that I have not reproduced the problem, I'm sort of "flying by instruments" here. I can see how this can happen, but can't think of a test I can build to generate the results your user reported. Your user can run the following command after installing flask-socketio with all its dependencies to override python-engineio with the github master version:
|
I will ask them and follow up in this thread when they respond. Thank you! |
Unfortunately they have not responded to my requests. I have nothing new to share at this time but wanted to let you know. |
Hi, I was looking for answers to a problem of my own running python 2.7, got here from a google search and thought this might help.
This raise inside the if that was casing this "TypeError: exceptions must be old-style" for me. |
socket.py in v2.0.1 raises an
Exception
with no type. This yields the errorTypeError: exceptions must be old-style classes or derived from BaseException, not NoneType
.The fix is to simply raise an exception type, such as
raise ValueError
.All instances of bare
raise
calls should be updated to raise a specific type. This is the only one I know of though.(noticed via cs01/gdbgui#144)
The text was updated successfully, but these errors were encountered: