[Python-checkins] cpython (2.7): 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/08e03dfb7dab
changeset:   97301:08e03dfb7dab
branch:      2.7
parent:      97257:6987a9c7dde9
user:        Robert Collins <rbtcollins at hp.com>
date:        Thu Aug 06 21:08:44 2015 +1200
summary:
  Issue #24531: Document that encoding lines cannot follow non-comment lines.

Patch from Terry Reedy

files:
  Doc/reference/lexical_analysis.rst |  7 ++++---
  1 files changed, 4 insertions(+), 3 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
@@ -109,7 +109,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> -*-
 
@@ -126,8 +128,7 @@
 encoding is used for all lexical analysis, in particular to find the end of a
 string, and to interpret the contents of Unicode literals. String literals are
 converted to Unicode for syntactical analysis, then converted back to their
-original encoding before interpretation starts. The encoding declaration must
-appear on a line of its own.
+original encoding before interpretation starts.
 
 .. XXX there should be a list of supported encodings.
 

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


More information about the Python-checkins mailing list