141 fn = detail.filename |
141 fn = detail.filename |
142 line = detail.lineno or 1 |
142 line = detail.lineno or 1 |
143 error = detail.msg |
143 error = detail.msg |
144 return (True, fn, int(line), index, code, error, []) |
144 return (True, fn, int(line), index, code, error, []) |
145 except ValueError as detail: |
145 except ValueError as detail: |
146 index = 0 |
|
147 code = "" |
|
148 try: |
146 try: |
149 fn = detail.filename |
147 fn = detail.filename |
150 line = detail.lineno |
148 line = detail.lineno |
151 error = detail.msg |
149 error = detail.msg |
152 except AttributeError: |
150 except AttributeError: |
153 fn = filename |
151 fn = filename |
154 line = 1 |
152 line = 1 |
155 error = str(detail) |
153 error = str(detail) |
156 return (True, fn, line, index, code, error, []) |
154 return (True, fn, line, 0, "", error, []) |
157 except Exception as detail: |
155 except Exception as detail: |
158 try: |
156 try: |
159 fn = detail.filename |
157 fn = detail.filename |
160 line = detail.lineno |
158 line = detail.lineno |
161 index = 0 |
|
162 code = "" |
|
163 error = detail.msg |
159 error = detail.msg |
164 return (True, fn, line, index, code, error, []) |
160 return (True, fn, line, 0, "", error, []) |
165 except: # this catchall is intentional |
161 except: # this catchall is intentional |
166 pass |
162 pass |
167 |
163 |
168 # pyflakes |
164 # pyflakes |
169 if not checkFlakes: |
165 if not checkFlakes: |
177 for warning in warnings.messages: |
173 for warning in warnings.messages: |
178 if ignoreStarImportWarnings and \ |
174 if ignoreStarImportWarnings and \ |
179 isinstance(warning, ImportStarUsed): |
175 isinstance(warning, ImportStarUsed): |
180 continue |
176 continue |
181 |
177 |
182 _fn, lineno, message, msg_args = warning.getMessageData() |
178 _fn, lineno, col, message, msg_args = warning.getMessageData() |
183 if "__IGNORE_WARNING__" not in extractLineFlags( |
179 if "__IGNORE_WARNING__" not in extractLineFlags( |
184 lines[lineno - 1].strip()): |
180 lines[lineno - 1].strip()): |
185 strings.append([ |
181 strings.append([ |
186 "FLAKES_WARNING", _fn, lineno, message, msg_args]) |
182 "FLAKES_WARNING", _fn, lineno, col, message, msg_args]) |
187 except SyntaxError as err: |
183 except SyntaxError as err: |
188 if err.text.strip(): |
184 if err.text.strip(): |
189 msg = err.text.strip() |
185 msg = err.text.strip() |
190 else: |
186 else: |
191 msg = err.msg |
187 msg = err.msg |
192 strings.append(["FLAKES_ERROR", filename, err.lineno, msg, ()]) |
188 strings.append(["FLAKES_ERROR", filename, err.lineno, 0, msg, ()]) |
193 |
189 |
194 return (False, "", -1, -1, "", "", strings) |
190 return (False, "", -1, -1, "", "", strings) |