Message311883
I have strange error with source encoding header. I usually use it from template which looks like:
#!/usr/bin/env python
# -*- coding: utf8 -*-
This works well on Linux machines with Python 2.x and 3.x, but on Windows machines it works well only with Python 2.x. When I use Python 3.6 it often works, but for some sources interpreter reports:
SyntaxError: encoding problem: utf8
It is easy to "correct": you can change "utf8" to "utf-8".
Strange thing is that even on Windows with Python 3.6 it works well with the same source encoding header but with little edited source file. I tried to create simplest file that shows this error but works well when I delete one empty line.
Error on Windows with Python 3.6:
c:\temp>C:\Users\mn\AppData\Local\Programs\Python\Python36-32\python.exe zz2_err
.py
File "zz2_err.py", line 2
SyntaxError: encoding problem: utf8
Works well with Python 2.7:
c:\temp>zz2_err.py
Python: 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
ver: $Id: zz.py 3367 2018-02-07 07:26:19Z mn $
Works well when I delete one empty line:
c:\temp>C:\Users\mn\AppData\Local\Programs\Python\Python36-32\python.exe zz2_err.py
Python: 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
ver: $Id: zz.py 3367 2018-02-07 07:26:19Z mn $
SHA1 sum of source that breaks Python 3.6:
c:\temp>fciv -sha1 zz2_err.py
//
// File Checksum Integrity Verifier version 2.05.
//
4176921690c9ea9259c57c9fcc3cda84aa51015e zz2_err.py
The same source on Linux works well with both Python 2.7 and Python 3.6:
[mn:] sha1sum zz2_err.py
4176921690c9ea9259c57c9fcc3cda84aa51015e zz2_err.py
[mn:] python zz2_err.py
Python: 2.7.13 (default, Dec 1 2017, 09:21:53)
[GCC 6.4.1 20170727 (Red Hat 6.4.1-1)]
ver: $Id: zz.py 3367 2018-02-07 07:26:19Z mn $
[mn:] python3 zz2_err.py
Python: 3.5.4 (default, Oct 9 2017, 12:07:29)
[GCC 6.4.1 20170727 (Red Hat 6.4.1-1)]
ver: $Id: zz.py 3367 2018-02-07 07:26:19Z mn $
[mn:] ll zz2_err.py
-rw-rw-r-- 1 mn mn 266 02-09 14:12 zz2_err.py |
|
Date |
User |
Action |
Args |
2018-02-09 13:20:30 | mniklas | set | recipients:
+ mniklas |
2018-02-09 13:20:30 | mniklas | set | messageid: <1518182430.26.0.467229070634.issue32809@psf.upfronthosting.co.za> |
2018-02-09 13:20:30 | mniklas | link | issue32809 messages |
2018-02-09 13:20:30 | mniklas | create | |
|