-
-
Notifications
You must be signed in to change notification settings - Fork 495
Turn off raising warnings via parameter #265
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
Turn off raising warnings via parameter #265
Conversation
Because warnings.catch_warnings() is not thread-safe. https://docs.python.org/3/library/warnings.html#warnings.catch_warnings
We should maybe also use |
Another way to do this would be with an envvar. That's what's used for insecure transports, for example, and it's also the approach I took in #268 for relaxing the If we proceed with the additional parameter to |
@whit537 using an envvar seems like a great idea, actually -- let me switch my pull request to do that. I don't think per-call configuration is necessary. |
@singingwolfboy Next question is what the default should be. Per the robustness principle I went with a non-strict default on #268. |
@whit537 I think it makes sense to raise the warning by default. First of all, it maintains backwards compatibility. Second, in single-threaded applications, you can just use If only |
@singingwolfboy Couldn't you just use try/except to catch warnings? try:
parse_token_response(token_response)
except Warning:
pass |
@whit537 not for my use case, because I need the output from the function that I'm calling, and raising an exception prevents me from getting the return value. Specifically, this is the code where the exception gets raised: |
Ah, okay. That makes sense. |
I figured it would be better to leave this PR as-is and simply create a new one, rather than removing my work. (Could be useful as a reference, or for comparison.) I've opened #269, and we can continue this discussion there. |
See oauthlib#265 for rationale. In brief: raising any exception blows the stack, which is inappropriate for a non-error state.
Because
warnings.catch_warnings()
is not thread-safe.https://docs.python.org/3/library/warnings.html#warnings.catch_warnings