Message411707
The linked code is for urllib.parse.urlencode, looking something like
try:
if len(query) and not isinstance(query[0], tuple):
raise TypeError
except TypeError:
ty, va, tb = sys.exc_info()
raise TypeError("not a valid non-string sequence "
"or mapping object").with_traceback(tb)
I guess it raises twice so that the error message is not duplicated in the code. The author probably also wants the TypeError initially raised from the "len(query)" and "query[0]" operations to get the same "not a valid . . ." message.
Regarding the OSError, originally it was catching socket.error and raising IOError. I guess someone only wanted the caller to have catch IOError and not need to import the socket module. Later these exception types became aliases of each other.
Anyway, the URLopener class is documented as deprecated, so is it really worth changing anything in that? |
|
Date |
User |
Action |
Args |
2022-01-26 06:00:06 | martin.panter | set | recipients:
+ martin.panter, orsenthil, iritkatriel |
2022-01-26 06:00:06 | martin.panter | set | messageid: <1643176806.61.0.671246343754.issue46517@roundup.psfhosted.org> |
2022-01-26 06:00:06 | martin.panter | link | issue46517 messages |
2022-01-26 06:00:06 | martin.panter | create | |
|