WeblateOrg / weblate

Unguarded next inside generator PTC-W0063
Bug risk
Critical
6 months ago4 years old
Call to next() should be wrapped in try-except
1639
1640        # Try reading header
1641        reader = csv.reader(fileobj, store.dialect)
1642        header = next(reader)1643        fileobj.close()
1644
1645        # Check if the file is not two column only, in that case translate-toolkit detection
Call to next() should be wrapped in try-except
223            raise MemoryImportError(
224                gettext("Could not parse TMX file: %s") % error
225            ) from error
226        header = next(227            storage.document.getroot().iterchildren(storage.namespaced("header"))
228        )
229        lang_cache = {}
Call to next() should be wrapped in try-except
100        # value can be None or blank stringfor cells having formatting only,
101        # we need to ignore such columns as that would be treated like "" fields
102        # later in the translate-toolkit
103        fields = [cell.value for cell in next(worksheet.rows) if cell.value]104        for row in worksheet.rows:
105            values = [cell.value for cell in row]
106            values = values[: len(fields)]