(line)
| 398 | raise SyntaxError(msg) |
| 399 | |
| 400 | def find_cookie(line): |
| 401 | match = cookie_re.match(line) |
| 402 | if not match: |
| 403 | return None |
| 404 | encoding = _get_normal_name(match.group(1).decode()) |
| 405 | try: |
| 406 | lookup(encoding) |
| 407 | except LookupError: |
| 408 | # This behaviour mimics the Python interpreter |
| 409 | if filename is None: |
| 410 | msg = "unknown encoding: " + encoding |
| 411 | else: |
| 412 | msg = "unknown encoding for {!r}: {}".format(filename, |
| 413 | encoding) |
| 414 | raise SyntaxError(msg) |
| 415 | |
| 416 | if bom_found: |
| 417 | if encoding != 'utf-8': |
| 418 | # This behaviour mimics the Python interpreter |
| 419 | if filename is None: |
| 420 | msg = 'encoding problem: utf-8' |
| 421 | else: |
| 422 | msg = 'encoding problem for {!r}: utf-8'.format(filename) |
| 423 | raise SyntaxError(msg) |
| 424 | encoding += '-sig' |
| 425 | return encoding |
| 426 | |
| 427 | first = read_or_stop() |
| 428 | if first.startswith(BOM_UTF8): |
no test coverage detected
searching dependent graphs…