Skip to content

Commit

Permalink
Merge pull request #3196 from washeck/3195-http-version-error
Browse files Browse the repository at this point in the history
Fix InvalidHTTPVersion exception str method
  • Loading branch information
benoitc authored Jul 4, 2024
2 parents 405c3ca + 97f87ec commit 79b9a52
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 79b9a52

Please sign in to comment.