Add int() calls in some places where they might be needed in the translation of %d to f-string

This commit is contained in:
Kovid Goyal 2025-02-01 12:48:28 +05:30
parent 18d57d6298
commit 4d6066163d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 4 additions and 4 deletions

View File

@ -194,7 +194,7 @@ def compress_readable_output(src_file, compress_level=6):
def get_range_parts(ranges, content_type, content_length): # {{{ def get_range_parts(ranges, content_type, content_length): # {{{
def part(r): def part(r):
ans = [f'--{MULTIPART_SEPARATOR}', f'Content-Range: bytes {r.start}-{r.stop}/{content_length}'] ans = [f'--{MULTIPART_SEPARATOR}', f'Content-Range: bytes {int(r.start)}-{int(r.stop)}/{content_length}']
if content_type: if content_type:
ans.append(f'Content-Type: {content_type}') ans.append(f'Content-Type: {content_type}')
ans.append('') ans.append('')
@ -719,7 +719,7 @@ class HTTPConnection(HTTPRequest):
if len(ranges) == 1: if len(ranges) == 1:
r = ranges[0] r = ranges[0]
outheaders.set('Content-Length', f'{r.size}', replace_all=True) outheaders.set('Content-Length', f'{r.size}', replace_all=True)
outheaders.set('Content-Range', f'bytes {r.start}-{r.stop}/{output.content_length}', replace_all=True) outheaders.set('Content-Range', f'bytes {int(r.start)}-{int(r.stop)}/{output.content_length}', replace_all=True)
output.ranges = r output.ranges = r
else: else:
range_parts = get_range_parts(ranges, outheaders.get('Content-Type'), output.content_length) range_parts = get_range_parts(ranges, outheaders.get('Content-Type'), output.content_length)

View File

@ -318,7 +318,7 @@ class RotatingStream:
for i in range(self.history - 1, 0, -1): for i in range(self.history - 1, 0, -1):
src, dest = f'{self.filename}.{i}', f'{self.filename}.{i + 1}' src, dest = f'{self.filename}.{i}', f'{self.filename}.{i + 1}'
self.rename(src, dest) self.rename(src, dest)
self.rename(self.filename, f'{self.filename}.{1}') self.rename(self.filename, f'{self.filename}.1')
self.set_output() self.set_output()
def clear(self): def clear(self):

View File

@ -430,7 +430,7 @@ class SchedulerConfig:
text = '%d:%d:%d'%schedule text = '%d:%d:%d'%schedule
elif typ in ('days_of_week', 'days_of_month'): elif typ in ('days_of_week', 'days_of_month'):
dw = ','.join(map(str, map(int, schedule[0]))) dw = ','.join(map(str, map(int, schedule[0])))
text = f'{dw}:{schedule[1]}:{schedule[2]}' text = f'{dw}:{int(schedule[1])}:{int(schedule[2])}'
else: else:
raise ValueError(f'Unknown schedule type: {typ!r}') raise ValueError(f'Unknown schedule type: {typ!r}')
s.text = text s.text = text