This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients PashaWNN, martin.panter
Date 2018-12-10.04:08:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1544414889.33.0.788709270274.issue35447@psf.upfronthosting.co.za>
In-reply-to
Content
Code in question:

try:
    # non-sequence items should not work with len()
    # non-empty strings will fail this
    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)

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
History
Date User Action Args
2018-12-10 04:08:09martin.pantersetrecipients: + martin.panter, PashaWNN
2018-12-10 04:08:09martin.pantersetmessageid: <1544414889.33.0.788709270274.issue35447@psf.upfronthosting.co.za>
2018-12-10 04:08:09martin.panterlinkissue35447 messages
2018-12-10 04:08:08martin.pantercreate