From 4d6066163d885c2df41da3edf83a2dfa81778db4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 1 Feb 2025 12:48:28 +0530 Subject: [PATCH] Add int() calls in some places where they might be needed in the translation of %d to f-string --- src/calibre/srv/http_response.py | 4 ++-- src/calibre/srv/utils.py | 2 +- src/calibre/web/feeds/recipes/collection.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calibre/srv/http_response.py b/src/calibre/srv/http_response.py index f9e2047dac..9aa0fac24e 100644 --- a/src/calibre/srv/http_response.py +++ b/src/calibre/srv/http_response.py @@ -194,7 +194,7 @@ def compress_readable_output(src_file, compress_level=6): def get_range_parts(ranges, content_type, content_length): # {{{ 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: ans.append(f'Content-Type: {content_type}') ans.append('') @@ -719,7 +719,7 @@ class HTTPConnection(HTTPRequest): if len(ranges) == 1: r = ranges[0] 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 else: range_parts = get_range_parts(ranges, outheaders.get('Content-Type'), output.content_length) diff --git a/src/calibre/srv/utils.py b/src/calibre/srv/utils.py index 730234eae6..83e1577692 100644 --- a/src/calibre/srv/utils.py +++ b/src/calibre/srv/utils.py @@ -318,7 +318,7 @@ class RotatingStream: for i in range(self.history - 1, 0, -1): src, dest = f'{self.filename}.{i}', f'{self.filename}.{i + 1}' self.rename(src, dest) - self.rename(self.filename, f'{self.filename}.{1}') + self.rename(self.filename, f'{self.filename}.1') self.set_output() def clear(self): diff --git a/src/calibre/web/feeds/recipes/collection.py b/src/calibre/web/feeds/recipes/collection.py index 18b02f9d9d..a1b14ce734 100644 --- a/src/calibre/web/feeds/recipes/collection.py +++ b/src/calibre/web/feeds/recipes/collection.py @@ -430,7 +430,7 @@ class SchedulerConfig: text = '%d:%d:%d'%schedule elif typ in ('days_of_week', 'days_of_month'): 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: raise ValueError(f'Unknown schedule type: {typ!r}') s.text = text