python / cpython

The Python programming language
https://www.python.org
Other
63.88k stars 30.58k forks source link

Better error messages for wsgiref validator failures #58857

Open f80b24cc-32aa-43d3-b7a7-c241e07eb45f opened 12 years ago

f80b24cc-32aa-43d3-b7a7-c241e07eb45f commented 12 years ago
BPO 14652
Nosy @berkerpeksag, @Sidnicious
Files
  • ssm_validate.patch
  • ssm_validate.patch: Don’t use tuples when using only len() to format a string
  • issue14652.diff
  • 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: ```python assignee = None closed_at = None created_at = labels = ['type-feature', 'library'] title = 'Better error messages for wsgiref validator failures' updated_at = user = 'https://github.com/Sidnicious' ``` bugs.python.org fields: ```python activity = actor = 'berker.peksag' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'ssm' dependencies = [] files = ['25320', '25624', '38131'] hgrepos = [] issue_num = 14652 keywords = ['patch'] message_count = 4.0 messages = ['159053', '160951', '160971', '235914'] nosy_count = 3.0 nosy_names = ['mcjeff', 'berker.peksag', 'ssm'] pr_nums = [] priority = 'normal' resolution = None stage = 'patch review' status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue14652' versions = ['Python 3.4', 'Python 3.5'] ```

    f80b24cc-32aa-43d3-b7a7-c241e07eb45f commented 12 years ago

    wsgiref’s validation middleware is missing messages for many of its assertions, and its docstring doesn’t reflect read() now requiring an argument (said that it took an optional argument).

    Here’s a patch to add some and update the comment.

    8c8022e7-f081-4d49-be03-926cedb53a7a commented 12 years ago

    I went through the patch real quick and I noticed that your using single element tuples in your string formatting. That makes sense in situations where the argument might itself be a tuple, however, not on calls to len() as that will return an integer.

    f80b24cc-32aa-43d3-b7a7-c241e07eb45f commented 12 years ago

    Thanks Jeff, I’m actually a relatively new Python developer and got the impression that it was best practice to always use a tuple for string formatting, for consistency.

    Here’s an updated patch which drops the tuples for those cases.

    berkerpeksag commented 9 years ago

    Here is an updated patch. For InputWrapper.read(), see bpo-18610.