Skip to content

Commit

Permalink
Fix InvalidHTTPVersion exception str method
Browse files Browse the repository at this point in the history
Fixes: #3195
  • Loading branch information
washeck committed Apr 26, 2024
1 parent 5b68c17 commit 97f87ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gunicorn/http/errors.py
Expand Up @@ -53,7 +53,7 @@ def __init__(self, version):
self.version = version

def __str__(self):
return "Invalid HTTP Version: %r" % self.version
return "Invalid HTTP Version: %r" % (self.version,)


class InvalidHeader(ParseException):
Expand Down
7 changes: 6 additions & 1 deletion tests/test_http.py
Expand Up @@ -9,7 +9,7 @@
from gunicorn.http.body import Body, LengthReader, EOFReader
from gunicorn.http.wsgi import Response
from gunicorn.http.unreader import Unreader, IterUnreader, SocketUnreader
from gunicorn.http.errors import InvalidHeader, InvalidHeaderName
from gunicorn.http.errors import InvalidHeader, InvalidHeaderName, InvalidHTTPVersion
from gunicorn.http.message import TOKEN_RE


Expand Down Expand Up @@ -238,3 +238,8 @@ def test_eof_reader_read_invalid_size():
reader.read([100])
with pytest.raises(ValueError):
reader.read(-100)


def test_invalid_http_version_error():
assert str(InvalidHTTPVersion('foo')) == "Invalid HTTP Version: 'foo'"
assert str(InvalidHTTPVersion((2, 1))) == 'Invalid HTTP Version: (2, 1)'

0 comments on commit 97f87ec

Please sign in to comment.