Martin Panter <vadmium...@gmail.com> added the comment:

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?

----------
nosy: +martin.panter

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46517>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to