[Python-checkins] cpython (merge 3.5 -> default): Issue #24531: Document that encoding lines cannot follow non-comment lines.

robert.collins python-checkins at python.org
Thu Aug 6 11:15:14 CEST 2015


https://hg.python.org/cpython/rev/82c9ce30c0a0
changeset:   97304:82c9ce30c0a0
parent:      97300:967c9a9fe724
parent:      97303:caecc1869921
user:        Robert Collins <rbtcollins at hp.com>
date:        Thu Aug 06 21:14:48 2015 +1200
summary:
  Issue #24531: Document that encoding lines cannot follow non-comment lines.

Patch from Terry Reedy

files:
  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
--- a/Doc/reference/lexical_analysis.rst
+++ b/Doc/reference/lexical_analysis.rst
@@ -81,7 +81,9 @@
 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 @@
 
 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.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list