Issue #1882: when compiling code from a string, encoding cookies in the

second line of code were not always recognized correctly.
This commit is contained in:
Georg Brandl 2008-01-21 18:35:49 +00:00
parent 2bdc48c6e0
commit 38d1715b0d
2 changed files with 22 additions and 3 deletions

View file

@ -1,5 +1,5 @@
#! -*- coding: koi8-r -*-
# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
# This file is marked as binary in SVN, to prevent MacCVS from recoding it.
import unittest
from test import test_support
@ -16,6 +16,14 @@ class PEP263Test(unittest.TestCase):
'\\\xd0\x9f'
)
def test_compilestring(self):
# see #1882
c = compile("\n# coding: utf-8\nu = u'\xc3\xb3'\n", "dummy", "exec")
d = {}
exec c in d
self.assertEqual(d['u'], u'\xf3')
def test_main():
test_support.run_unittest(PEP263Test)