Terry J. Reedy added the comment: [When responding, please do not quote more than a line or two. If responding by email, please delete the rest. Otherwise, the result is extra noise when viewing online.]
You are right, I missed the outer 's, though my examples are not completely irrelevant. Eval looks inside the inner quotes for a coding line in certain circumstances, or maybe it always looks and we do not notice when there is not problem. Here are some of my results on US Win 7, cp1252, 3.4.1, interactive prompt, idle pass: eval(u'"""# -*- coding: utf-8 -*-\na"""') fail: eval(u'"""\n# -*- coding: utf-8 -*-\na"""') since coding can be on line 1 or 2, these should be same pass: eval(u'"""\n\n# -*- coding: utf-8 -*-\na"""') coding on 3rd line should be ignored fail: eval(u'"""\\\n# -*- coding: utf-8 -*-\na"""') logically, this matches the first example; physically, the second pass: eval(u'"""# -*- coding: utf-8 -*-\na€"""') but € prints as \xc2\x80', its utf-8 encoding as pasted in >From file, saved from Idle editor as cp1252 pass: print(eval("# -*- coding: utf-8 -*-\n'euro€'")) no u prefix, € prints as € fail: print(eval(u"# -*- coding: utf-8 -*-\n'euro€'")) Save the following two lines in one file as utf-8 pass: print(eval("# -*- coding: utf-8 -*-\n'euro€'")) print(eval(u"# -*- coding: utf-8 -*-\n'euro∢'")) but € & ∢ print as '€' & '∢' adding # -*- coding: utf-8 -*- line makes no difference adding u prefix fails either way ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22221> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com