Skip to content

Commit 7c9247d

Browse files
committed
chore(ruff): use names not magic numbers.
This one names the 32 chars as being equivalent to 256 bytes Also adds the missing http_.client.TOO_MANY_REQUESTS under python 2 to http_. It allows me to use a symbolic name and not have to touch client.py code when I remove python2 support from http_. Also the prior checkin had a bogus commit message. Sigh, time to step away from the computer today 8-). It replaced a magic number with MAX_MIME_EXTENSION_LENGTH which was set to a better magic number derived by parsing extensions in /etc/mime.types.
1 parent 2331ab5 commit 7c9247d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

roundup/anypy/http_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
# Python 2.5-2.7
66
import BaseHTTPServer as server # noqa: F401
77
import httplib as client # noqa: F401
8+
client.TOO_MANY_REQUESTS = 429

roundup/cgi/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,8 @@ def handle_rest(self):
709709
return
710710
except RateLimitExceeded as err:
711711
output = s2b("%s" % str(err))
712-
# PYTHON2:FIXME http_.client.TOO_MANY_REQUESTS missing
713-
# python2 so use numeric code.
714-
self.reject_request(output, status=429)
712+
self.reject_request(output,
713+
status=http_.client.TOO_MANY_REQUESTS)
715714
return
716715

717716
# verify Origin is allowed on all requests including GET.
@@ -1156,7 +1155,8 @@ def authenticate_bearer_token(self, challenge):
11561155
# If second or later tokens are < 32 chars, the config system
11571156
# stops the tracker from starting so insecure tokens can not
11581157
# be used.
1159-
if len(self.db.config.WEB_JWT_SECRET[0]) < 32:
1158+
CHARS_FOR_256_BIT_KEY = 32
1159+
if len(self.db.config.WEB_JWT_SECRET[0]) < CHARS_FOR_256_BIT_KEY:
11601160
# no support for jwt, this is fine.
11611161
self.setHeader("WWW-Authenticate", "Basic")
11621162
raise LoginError('Support for jwt disabled by admin.')

0 commit comments

Comments
 (0)