Message225716
[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 |
|
Date |
User |
Action |
Args |
2014-08-22 22:48:41 | terry.reedy | set | recipients:
+ terry.reedy, serhiy.storchaka, davidhalter, jorgenschaefer |
2014-08-22 22:48:40 | terry.reedy | set | messageid: <1408747720.98.0.551885330169.issue22221@psf.upfronthosting.co.za> |
2014-08-22 22:48:40 | terry.reedy | link | issue22221 messages |
2014-08-22 22:48:40 | terry.reedy | create | |
|