284 @return tuple containing the error dictionary with syntax error details |
280 @return tuple containing the error dictionary with syntax error details |
285 and a statistics dictionary or a tuple containing two None |
281 and a statistics dictionary or a tuple containing two None |
286 @rtype tuple of (dict, dict) or tuple of (None, None) |
282 @rtype tuple of (dict, dict) or tuple of (None, None) |
287 """ |
283 """ |
288 src = "".join(source) |
284 src = "".join(source) |
289 # Check type for py2: if not str it's unicode |
|
290 if sys.version_info[0] == 2: |
|
291 try: |
|
292 src = src.encode('utf-8') |
|
293 except UnicodeError: |
|
294 pass |
|
295 |
285 |
296 try: |
286 try: |
297 ast.parse(src, filename, 'exec') |
287 ast.parse(src, filename, 'exec') |
298 return None, None |
288 return None, None |
299 except (SyntaxError, TypeError): |
289 except (SyntaxError, TypeError): |