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
Redundant try-except block in urllib #79628
Comments
https://github.com/python/cpython/blob/master/Lib/urllib/parse.py#L875 |
Code in question: try: It is not redundant if you want a specific error message. I think that is the point of the code, to indicate the problem to the programmer. So the message is meant to be useful. I can think of three cases: >>> urlencode(None) # Non-sequence
TypeError: not a valid non-string sequence or mapping object
>>> urlencode({'sized but not indexable'})
TypeError: not a valid non-string sequence or mapping object
>>> urlencode('item [0] not a tuple')
TypeError: not a valid non-string sequence or mapping object |
https://github.com/python/cpython/blob/master/Lib/urllib/parse.py#L875 I mean: Would be more clean. |
That would not include the custom error message for the first two cases I listed. I suggest closing this. |
I concur with Martin. The try-except block was added for purpose. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: