New submission from Florent Xicluna <florent.xicl...@gmail.com>:

I've hit this issue while playing with tokenize for the pep8.py module.

The tokenize detect_encoding() should report SyntaxError when the encoding is 
improperly declared.

However it raises a LookupError in some cases.

$ ./python -m tokenize Lib/test/bad_coding2.py 
unexpected error: unknown encoding: utf8-sig
Traceback (most recent call last):
  File "./Lib/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "./Lib/runpy.py", line 75, in _run_code
    exec(code, run_globals)
  File "./Lib/tokenize.py", line 686, in <module>
    main()
  File "./Lib/tokenize.py", line 656, in main
    tokens = list(tokenize(f.readline))
  File "./Lib/tokenize.py", line 489, in _tokenize
    line = line.decode(encoding)
LookupError: unknown encoding: utf8-sig

----------
components: Library (Lib)
messages: 162205
nosy: flox
priority: normal
severity: normal
stage: needs patch
status: open
title: detect_encoding should fail with SyntaxError on invalid encoding
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14990>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to