From 289ebadbb4f57979ae0928443ae653d8d3a6b615 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 20 Apr 2011 18:24:13 +0300 Subject: [PATCH] orm: at csv import, properly report lines with less columns The "if not line[i]" check would cause an IndexError earlier than the exception. Also, report the line number where that happened. (the +2 op. is needed because we skip 1 for header and count at 0) (cherry picked from commit 7f7e84e32405d4552b8f1b156d359d629bbca353) bzr revid: p_christ@hol.gr-20110420152413-knedwepb0tmersw4 --- bin/osv/orm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 91574e7fa6a..947d9024429 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -762,10 +762,12 @@ class orm_template(object): done = {} for i in range(len(fields)): res = False + if i >= len(line): + raise Exception(_('Please check that all your lines have %d columns.' + 'Stopped around line %d having %d columns.') % \ + (len(fields), position+2, len(line))) if not line[i]: continue - if i >= len(line): - raise Exception(_('Please check that all your lines have %d columns.') % (len(fields),)) field = fields[i] if field[:len(prefix)] <> prefix: