This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unhelpful error message on invalid encoding specification
Type: behavior Stage: resolved
Components: Interpreter Core, Unicode Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Max.Cantor, ezio.melotti, loewis, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-05-22 22:43 by Max.Cantor, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tokenizer_encoding_problem_msg.patch serhiy.storchaka, 2013-05-24 10:09 review
Messages (6)
msg189840 - (view) Author: Max Cantor (Max.Cantor) Date: 2013-05-22 22:43
When you specify a nonexistent encoding at the top of a file, like so for example:

# -*- coding: fakefakefoobar -*-

The following exception occurs:

SyntaxError: encoding problem: with BOM

This is very unhelpful, especially in cases where you might have made a typo in the encoding.
msg189846 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-23 04:31
Here is a patch.
msg189903 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2013-05-24 09:53
LGTM.
msg189905 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-24 10:09
Here is a better patch with tests (see also issue18048).
msg190856 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-06-09 13:59
New changeset 15aa786b723b by Serhiy Storchaka in branch '3.3':
Issue #18038: SyntaxError raised during compilation sources with illegal
http://hg.python.org/cpython/rev/15aa786b723b

New changeset 39e2f0059ee2 by Serhiy Storchaka in branch 'default':
Issue #18038: SyntaxError raised during compilation sources with illegal
http://hg.python.org/cpython/rev/39e2f0059ee2

New changeset 570b5b4040b1 by Serhiy Storchaka in branch '2.7':
Issue #18038: SyntaxError raised during compilation sources with illegal
http://hg.python.org/cpython/rev/570b5b4040b1
msg192075 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-06-30 15:51
New changeset 19bc00996e74 by R David Murray in branch '3.3':
#18038: Use non-deprecated assert names in tests.
http://hg.python.org/cpython/rev/19bc00996e74

New changeset 29e7f6a2dc0d by R David Murray in branch 'default':
Null merge #18038: Use non-deprecated assert names in tests.
http://hg.python.org/cpython/rev/29e7f6a2dc0d
History
Date User Action Args
2022-04-11 14:57:45adminsetgithub: 62238
2013-06-30 15:51:09python-devsetmessages: + msg192075
2013-06-09 14:13:49serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-06-09 13:59:01python-devsetnosy: + python-dev
messages: + msg190856
2013-06-08 22:51:10serhiy.storchakasetassignee: serhiy.storchaka
2013-05-24 11:54:36serhiy.storchakasetfiles: - tokenizer_encoding_problem_msg.patch
2013-05-24 10:09:30serhiy.storchakasetfiles: + tokenizer_encoding_problem_msg.patch

messages: + msg189905
2013-05-24 09:53:58loewissetnosy: + loewis
messages: + msg189903
2013-05-23 04:31:27serhiy.storchakasetfiles: + tokenizer_encoding_problem_msg.patch

components: + Interpreter Core, Unicode, - Library (Lib)
versions: + Python 3.3, Python 3.4
keywords: + patch
nosy: + serhiy.storchaka, ezio.melotti

messages: + msg189846
stage: patch review
2013-05-22 22:43:16Max.Cantorcreate