diff options
author | Robert Collins <rbtcollins@hp.com> | 2015-08-06 09:14:34 (GMT) |
---|---|---|
committer | Robert Collins <rbtcollins@hp.com> | 2015-08-06 09:14:34 (GMT) |
commit | 888a6729da50a819438c6aa47e5ea7999d039b24 (patch) | |
tree | d8f3de5e23abc539c86cbc7d821b75f4355224e8 /Doc/reference | |
parent | d987a81d29a16215fff6dd9670cedbcdac82d1b0 (diff) | |
parent | 0b2833eaf2f21f0d70cee07eea39e139fd5ce1ef (diff) | |
download | cpython-888a6729da50a819438c6aa47e5ea7999d039b24.zip cpython-888a6729da50a819438c6aa47e5ea7999d039b24.tar.gz cpython-888a6729da50a819438c6aa47e5ea7999d039b24.tar.bz2 |
Issue #24531: Document that encoding lines cannot follow non-comment lines.
Patch from Terry Reedy
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/lexical_analysis.rst | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst index 27d6a8a..8ad975f 100644 --- a/Doc/reference/lexical_analysis.rst +++ b/Doc/reference/lexical_analysis.rst @@ -81,7 +81,9 @@ Encoding declarations If a comment in the first or second line of the Python script matches the regular expression ``coding[=:]\s*([-\w.]+)``, this comment is processed as an encoding declaration; the first group of this expression names the encoding of -the source code file. The recommended forms of this expression are :: +the source code file. The encoding declaration must appear on a line of its +own. If it is the second line, the first line must also be a comment-only line. +The recommended forms of an encoding expression are :: # -*- coding: <encoding-name> -*- @@ -98,7 +100,7 @@ among others, by Microsoft's :program:`notepad`). If an encoding is declared, the encoding name must be recognized by Python. The encoding is used for all lexical analysis, including string literals, comments -and identifiers. The encoding declaration must appear on a line of its own. +and identifiers. .. XXX there should be a list of supported encodings. |