From 7ea4c3e9256c3cc7261238f5c95758cdd3a5bbe5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 24 Jul 2023 11:48:58 +0200 Subject: [PATCH] Continued: - let's not iterate directly (always possible, of course) on the CSV reader object, but generate a list from its rows - this also allow us to check if 'reader' is not NoneType --- fba/commands.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fba/commands.py b/fba/commands.py index 08b9dda..1ef5ab6 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1614,7 +1614,14 @@ def fetch_fedilist(args: argparse.Namespace) -> int: reader = csv.DictReader(response.content.decode("utf-8").splitlines(), dialect="unix") logger.debug("reader[]='%s'", type(reader)) - for row in reader: + if reader is None: + logger.warning("Failed parsing response.content()=%d as CSV content", len(response.content)) + return 2 + + rows = list(reader) + + logger.info("Checking %d rows ...", len(rows)) + for row in rows: logger.debug("row[]='%s'", type(row)) if "hostname" not in row: logger.warning("row()=%d has no element 'hostname' - SKIPPED!", len(row)) -- 2.39.5