@@ -58,7 +58,7 @@ def _decode_header_lines(lines):
58
58
# Python 3, validate() takes either and returns matches as bytes. But
59
59
# on Python 2, validate can return matches as bytearrays, so we have
60
60
# 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 ) )
62
62
yield (matches ["field_name" ], matches ["field_value" ])
63
63
64
64
@@ -71,7 +71,7 @@ def maybe_read_from_IDLE_client(buf):
71
71
return None
72
72
if not lines :
73
73
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 ] )
75
75
return Request (
76
76
headers = list (_decode_header_lines (lines [1 :])), _parsed = True , ** matches
77
77
)
@@ -86,7 +86,7 @@ def maybe_read_from_SEND_RESPONSE_server(buf):
86
86
return None
87
87
if not lines :
88
88
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 ] )
90
90
# Tolerate missing reason phrases
91
91
if matches ["reason" ] is None :
92
92
matches ["reason" ] = b""
@@ -152,7 +152,7 @@ def __call__(self, buf):
152
152
chunk_header = buf .maybe_extract_until_next (b"\r \n " )
153
153
if chunk_header is None :
154
154
return None
155
- matches = validate (chunk_header_re , chunk_header )
155
+ matches = validate (chunk_header_re , chunk_header , "illegal chunk header: {!r}" , chunk_header )
156
156
# XX FIXME: we discard chunk extensions. Does anyone care?
157
157
# We convert to bytes because Python 2's `int()` function doesn't
158
158
# work properly on bytearray objects.
0 commit comments