This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients davidhalter, jorgenschaefer, serhiy.storchaka, terry.reedy
Date 2014-08-22.22:48:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1408747720.98.0.551885330169.issue22221@psf.upfronthosting.co.za>
In-reply-to
Content
[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
History
Date User Action Args
2014-08-22 22:48:41terry.reedysetrecipients: + terry.reedy, serhiy.storchaka, davidhalter, jorgenschaefer
2014-08-22 22:48:40terry.reedysetmessageid: <1408747720.98.0.551885330169.issue22221@psf.upfronthosting.co.za>
2014-08-22 22:48:40terry.reedylinkissue22221 messages
2014-08-22 22:48:40terry.reedycreate