Skip to content
Snippets Groups Projects
Unverified Commit 07b88c54 authored by Andrew Morgan's avatar Andrew Morgan Committed by GitHub
Browse files

Convert http.HTTPStatus objects to their int equivalent (#7188)

parent 0f05fd15
No related branches found
No related tags found
No related merge requests found
Fix consistency of HTTP status codes reported in log lines.
...@@ -86,7 +86,14 @@ class CodeMessageException(RuntimeError): ...@@ -86,7 +86,14 @@ class CodeMessageException(RuntimeError):
def __init__(self, code, msg): def __init__(self, code, msg):
super(CodeMessageException, self).__init__("%d: %s" % (code, msg)) super(CodeMessageException, self).__init__("%d: %s" % (code, msg))
self.code = code
# Some calls to this method pass instances of http.HTTPStatus for `code`.
# While HTTPStatus is a subclass of int, it has magic __str__ methods
# which emit `HTTPStatus.FORBIDDEN` when converted to a str, instead of `403`.
# This causes inconsistency in our log lines.
#
# To eliminate this behaviour, we convert them to their integer equivalents here.
self.code = int(code)
self.msg = msg self.msg = msg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment