@@ -58,7 +58,7 @@ def _decode_header_lines(lines):
5858 # Python 3, validate() takes either and returns matches as bytes. But
5959 # on Python 2, validate can return matches as bytearrays, so we have
6060 # to explicitly cast back.
61- matches = validate (header_field_re , bytes (line ))
61+ matches = validate (header_field_re , bytes (line ), "illegal header line: {!r}" , bytes ( line ) )
6262 yield (matches ["field_name" ], matches ["field_value" ])
6363
6464
@@ -71,7 +71,7 @@ def maybe_read_from_IDLE_client(buf):
7171 return None
7272 if not lines :
7373 raise LocalProtocolError ("no request line received" )
74- matches = validate (request_line_re , lines [0 ])
74+ matches = validate (request_line_re , lines [0 ], "illegal request line: {!r}" , lines [ 0 ] )
7575 return Request (
7676 headers = list (_decode_header_lines (lines [1 :])), _parsed = True , ** matches
7777 )
@@ -86,7 +86,7 @@ def maybe_read_from_SEND_RESPONSE_server(buf):
8686 return None
8787 if not lines :
8888 raise LocalProtocolError ("no response line received" )
89- matches = validate (status_line_re , lines [0 ])
89+ matches = validate (status_line_re , lines [0 ], "illegal status line: {!r}" , lines [ 0 ] )
9090 # Tolerate missing reason phrases
9191 if matches ["reason" ] is None :
9292 matches ["reason" ] = b""
@@ -152,7 +152,7 @@ def __call__(self, buf):
152152 chunk_header = buf .maybe_extract_until_next (b"\r \n " )
153153 if chunk_header is None :
154154 return None
155- matches = validate (chunk_header_re , chunk_header )
155+ matches = validate (chunk_header_re , chunk_header , "illegal chunk header: {!r}" , chunk_header )
156156 # XX FIXME: we discard chunk extensions. Does anyone care?
157157 # We convert to bytes because Python 2's `int()` function doesn't
158158 # work properly on bytearray objects.
0 commit comments