Mariatta Wijaya added the comment:
There are certain rules about the encoding declaration line. It has to be the first line of the source code, or in the case that the file starts with a unix "shebang" line, then the encoding declaration has to be on the second line. In fact, the first or the second lines of the source code has to follow a certain regular expression. This is all described in PEP 263, but we don't have to repeat all of those here. IMO we can just refer the reader to the PEP.
I've prepared a patch that addresses this. Please review, and let me know if you have additional feedback.
---------- Added file: http://bugs.python.org/file46452/issue29381.patch