Steven Winfield added the comment:

I've just been bitten by this on 3.6.2, Windows Server 2008 R2, when running 
the script for QuantLib-SWIG:

It seems there is different behaviour depending on whether:
  * Unix (LF) or Windows (CRLF) line endings are used
  * The file is >4096 bytes or <=4096 bytes
  * The module docstring has an initial space

Some of that has been mentioned previously, but I think the 4096-byte limit 
might be new, which is why I'm posting.

I've attached a script I used to come up with the results below. It contains:
  * a -*- coding line (for iso-8859-1 in this case)
  * a docstring consisting entirely of lines of x's, of length 78
  * Unix line endings

The file's length is exactly 4096 bytes.

Running this, or slightly modified versions of this, with a 3.6.2 interpreter 
gave the following results:

  * In all cases, when Windows line endings were used there was no issue - 
running the script produced no errors or output.

  * With Unix line endings:

    * File length <= 4096, with no leading spaces in the docstring:
          File "", line 1
        SyntaxError: encoding problem: iso-8859-1

    * File length > 4096, with no leading spaces in the docstring:
          File "", line 56
        SyntaxError: EOF while scanning triple-quoted string literal

    * Any file length, with the first 'x' on line 3 replaced with a space (line 
2 if the coding line is ignored):
          File "", line 2
        IndentationError: unexpected indent

I had no issues with python 2.7.13.

nosy: +steven.winfield
versions: +Python 3.6
Added file:

Python tracker <>
Python-bugs-list mailing list

Reply via email to