WeblateOrg / weblate

Unguarded next inside generator PTC-W0063
Bug risk
Critical
2 months ago3 years old
Call to next() should be wrapped in try-except
1621
1622        # Try reading header
1623        reader = csv.reader(fileobj, store.dialect)
1624        header = next(reader)1625        fileobj.close()
1626
1627        # Check if the file is not two column only
Call to next() should be wrapped in try-except
 93        # value can be None or blank stringfor cells having formatting only,
 94        # we need to ignore such columns as that would be treated like "" fields
 95        # later in the translate-toolkit
 96        fields = [cell.value for cell in next(worksheet.rows) if cell.value] 97        for row in worksheet.rows:
 98            values = [cell.value for cell in row]
 99            values = values[: len(fields)]
Call to next() should be wrapped in try-except
204            raise MemoryImportError(
205                gettext("Could not parse TMX file: %s") % error
206            ) from error
207        header = next(208            storage.document.getroot().iterchildren(storage.namespaced("header"))
209        )
210        lang_cache = {}